Deploying React-App on Github-Pages
We can host out react-static-application on github-pages as follows:
# Install package
npm install gh-pages --save-dev
Modify Package.json
as:
Add the following attribute:
"homepage": "http://{github-username}.github.io/<REPO_NAME>",
# Append the following to scripts
"scripts": {
...
"predeploy" : "npm run build",
"deploy" : "gh-pages -d build"
}
Create a new-file public\_redirects
with contents
/* /index.html 200
This will configure the redirects appropriately
Now, Commit and push your changes:
In order to Deploy, run the following command which will build the project and push it to 'gh-pages' branch from which it will be deployed, that can be verify from Settings > Pages in our Repo-Settings
npm run deploy
For more information, Please refer here