How to deploy React GitHub Pages

How to deploy React GitHub Pages

  1. In the command line: direct to your project name position
cd <project name>
  1. Go to your GitHub to build a new repository

You can find the HTTPS or SSH on the right side in the code button

  1. In the command line: add local project files remotely to GitHub location
cd <project name>
  1. Change the package.json file:

In package.json add “homepage”, “predeploy” and “deploy”

  1. Run the command line to deploy
npm deploy

git add .
git commit -m 'deploy pages to github'
git push origin master

Now your pages are deployed to GitHub

Btw since the <master> changed to <main>, you can run

git push origin main
  1. Looking up the URL of your project

Go to the GitHub repository of your project then setting to see the URL, make sure the root is gh-pages

Hurray!!! The site is published now.🤩

You can follow me on Twitter at @MSujata13 or on LinkedIn at @mishrasujata

If you find this article helpful, please share it with others 🗣 and do clap 👏