Deploying React App to GitHub Pages
Create a react app
npm init react-app {react-app-name}
Create an empty repository in GitHub with the same name of the react app.
git remote add origin https://github.com/{github-username}/{repo-name}
Note: Replace {github-username} with your GitHub username and {repo-name} with your repository name.
Install gh-pages package and save it as a dev dependency.
npm install gh-pages --save-dev
In package.json, add this line
homepage: "https://{github-username}.github.io/{repository-name}",
Under scripts, add these two lines
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
Push all your code to the remote GitHub repository.
Now, run this command
npm run deploy
On the browser, go to → https://{github-username}.github.io/{repository-name}
Yay!!! Our react app is published using GitHub Pages! 🎉