Skip to main content

Deploying a React app to GitHub Pages

· One min read
Preet Shah
Software Developer @ JPMC

To deploy a React app to GitHub Pages, follow the instructions below:

  1. Install gh-pages as a dev depedency: npm install -D gh-pages
  2. In package.json add the following in scripts:
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"build": "react-scripts build && cp build/index.html build/404.html",
  1. Run npm run deploy to deploy the site to GitHub Pages.

NOTE: On Windows cmd, it will be copy instead of cp.

References