Deploying a React app to GitHub Pages
· One min read
To deploy a React app to GitHub Pages, follow the instructions below:
- Install gh-pages as a dev depedency:
npm install -D gh-pages
- 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",
- Run
npm run deploy
to deploy the site to GitHub Pages.
NOTE: On Windows cmd, it will be copy
instead of cp
.