React - Deploy to Github Pages

Add the gh-pages package:

🌹 yarn add gh-pages

In package.json file add a key homepage with the GitHub Page address:

{
  "name": "monsters-rolodex",
  "version": "0.1.0",
  "private": true,
  "homepage": "https://[github-username].github.io/<repo-name>",
  [...]
}

Inside the scripts key add two scripts: predeploy and deploy

"scripts": {
  "start": "react-scripts start",
  "build": "react-scripts build",
  "test": "react-scripts test",
  "eject": "react-scripts eject",
  "predeploy": "yarn build",
  "deploy": "gh-pages -d build
}

Run the deploy script:

🌹 yarn deploy

Reference: