Skip to content

Instantly share code, notes, and snippets.

@shivampip
Last active July 9, 2020 11:39
Show Gist options
  • Save shivampip/a82a79eb80a99de5b3131c190203aaba to your computer and use it in GitHub Desktop.
Save shivampip/a82a79eb80a99de5b3131c190203aaba to your computer and use it in GitHub Desktop.
Deploy React App on Github Pages

Deploy React App on Github Pages

  • 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

Behind the scene

gh-pages module create a new branch named gh-pages in our github repo and deploys the static files there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment