- My github username is
shivampip
, in below steps, replace it with yours - Say you have a react app named
ghtest
- Create new repo on github with same name as react app. i.e.
ghtest
- Now on local react app repo, install gh-pages module
npm install --save gh-pages
- Now in
package.json
, add these line below name
"homepage": "https://shivampip.github.io/ghtest",
- Add these lines inside script object in same file
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
- Now connect to github repo
git init
git remote add origin https://github.com/shivampip/ghtest.git
- Optionally you can commit and push changes
git add .
git commid -m "ititial commit"
git push origin master
- Finally Deploy it
npm run deploy
- Congratulations, You have successfully deployed React app on Github pages.
- Browse here: https://shivampip.github.io/ghtest
gh-pages
module create a new branch named gh-pages
in our github repo and deploys the static files there.