https://github.com/gitname/react-gh-pages

From GitHub Site From Starting:

  1. Create an empty repository on GitHub without README File

  2. Install the gh-pages npm package in Terminal

    npm install gh-pages --save-dev
    
  3. Add it to local Choose a Folder and Add a remote that points to the GitHub repository

    git init
    git add README.md
    git commit -m "first commit"
    git branch -M main
    git remote add origin <https://github.com/{username}/{repo-name}.git>
    git push -u origin main
    
  4. Create a React app

    npm init react-app {appName}
    
  5. Add a homepage property to the package.json file

    {
      "name": "my-app",
      "version": "0.1.0",
    + "homepage": "https://{username}.github.io/{repo-name}",
      "private": true,
    
  6. Add deployment scripts to the package.json file

    "scripts": {
    +   "predeploy": "npm run build",
    +   "deploy": "gh-pages -d build",
        "start": "react-scripts start",
        "build": "react-scripts build",
    
  7. Push the React app to the GitHub repository

    npm run deploy -- -m "Deploy React app to GitHub Pages"
    

From VS Code to Deploy New Project:

  1. Create react app
  2. Push to GitHub From VS Code Directly By selecting Public or Private Repository and branch
  3. Follow Steps - 2 , 4 , 5 , 6 , commit all changes and step - 7

From VS Code to Re-Deploy Existing Project:

Do commit all changes and step - 7

Last Updated : January 27, 2024