You need to install GitHub Pages package as a dev-dependency.

cd ./into/your-app-folder
npm install gh-pages --save-dev

Add properties to package.json file.

The first property you need to add at the top level homepage, second you must define this as a string and the value will be "https://{your-username}.github.io/{repo-name}" , {repo-name} is the name of the GitHub repository you created it will look like this :

"homepage": "http://joedoe.github.io/your-app"

Second in the existing scripts property you need to add predeploy and deploy.

"scripts": {
//...
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}

If you pushed everything already to Github, the last step is deploying. One liner:

npm run deploy

With this Github will create a new branch called gh-pages, and will be available online. Hope I could help and will work accordingly.

If you stuck, you can look it up on the official docs of React. Deployment Documentation of React

Once on a deployment I had some issues with the official documentation, and I had to delete my username from the "homepage" property in order to make it work. Although I suggest you first do by the docs, and if you encounter problems, you might can give a try.

Answer from Benji on Stack Overflow
🌐
GitHub
github.com › gitname › react-gh-pages
GitHub - gitname/react-gh-pages: Deploying a React App (created using create-react-app) to GitHub Pages · GitHub
Commit the changes you made while you were following this tutorial, to the master branch of the local Git repository; then, push that branch up to the master branch of the GitHub repository.
Starred by 7K users
Forked by 970 users
Languages   TypeScript 43.0% | HTML 37.0% | CSS 20.0%
🌐
Create React App
create-react-app.dev › docs › deployment
Deployment | Create React App
Add in the details and connect to your GitHub repo. Make sure the build folder is set correctly on the "build" tab and create the resource. Azure Static Web Apps will automatically configure a GitHub Action in your repo and begin the deployment.
Discussions

React on Github Pages
For those who might have gotten stuck on 'npm run deploy, This will create a branch called gh-pages in your ... ' You may have come across a 'Failed to get remote.origin.url' error in your terminal. You may want to initialize a local git repository inside your react-app directory (git init) ... More on github.com
🌐 github.com
4
3
July 14, 2023
node.js - ReactJS: How to deploy on local server - Stack Overflow
I have a web app developed with ... and a ReactJS + Apollo front-end. I would like to deploy this application locally. Is that even possible? I have come across dozens of "how to deploy to Heroku," "how to deploy to Digital Ocean", "how to deploy to Github", et... More on stackoverflow.com
🌐 stackoverflow.com
How would I deploy a static front end react app on GitHub pages?
You upload the contents of the build folder to another branch, then in repository settings enable GitHub pages for that branch More on reddit.com
🌐 r/react
9
1
November 26, 2024
I wrote a guide to help you deploy a React app automatically with GitHub Actions, Docker, and Heroku
If I’m a beginner, wouldn’t I be better served by skipping the Docker and Heroku and deploying to something like Netlify with a npm run build command? What value does Docker bring when I’m deploying a static bundle of JS? More on reddit.com
🌐 r/reactjs
16
352
March 22, 2021
Top answer
1 of 3
11

You need to install GitHub Pages package as a dev-dependency.

cd ./into/your-app-folder
npm install gh-pages --save-dev

Add properties to package.json file.

The first property you need to add at the top level homepage, second you must define this as a string and the value will be "https://{your-username}.github.io/{repo-name}" , {repo-name} is the name of the GitHub repository you created it will look like this :

"homepage": "http://joedoe.github.io/your-app"

Second in the existing scripts property you need to add predeploy and deploy.

"scripts": {
//...
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}

If you pushed everything already to Github, the last step is deploying. One liner:

npm run deploy

With this Github will create a new branch called gh-pages, and will be available online. Hope I could help and will work accordingly.

If you stuck, you can look it up on the official docs of React. Deployment Documentation of React

Once on a deployment I had some issues with the official documentation, and I had to delete my username from the "homepage" property in order to make it work. Although I suggest you first do by the docs, and if you encounter problems, you might can give a try.

2 of 3
1

You have to do the following things:

  1. Push your project to GitHub

    git add .
    git commit -m "Your message"
    git push
    
  2. To create a page on GitHub, you should:

    1. Add this to your package.json: "homepage": "https://myusername.github.io/my-app",

    2. npm install --save gh-pages

    3. Add the following scripts in your package.json

      "scripts": {
        "predeploy": "npm run build",
        "deploy": "gh-pages -d build",
        "start": "react-scripts start",
        "build": "react-scripts build",
      }
      
  3. Run npm run deploy

Now you'll have a new branch and your page in GitHub will be creating from this new branch.

🌐
DhiWise
dhiwise.com › post › simplify-deployment-how-to-deploy-react-app-to-github-page
How to Deploy React App to Github Pages: A Comprehensive Guide
September 5, 2024 - Commit the changes to your local git repository using a meaningful commit message: ... Each time you run the deploy command, the updated version of your app will be pushed to the gh-pages branch, and GitHub Pages will serve the latest build.
🌐
LogRocket
blog.logrocket.com › home › how to deploy react apps to github pages
How to deploy React apps to GitHub Pages - LogRocket Blog
April 22, 2025 - Walk through deploying a Create React App project to GitHub Pages, customizing your domain, and automating deployments with GitHub Actions.
🌐
freeCodeCamp
freecodecamp.org › news › deploy-a-react-app-to-github-pages
How to Deploy a Routed React App to GitHub Pages
February 22, 2021 - ReactDOM.render( <React.StrictMode> <BrowserRouter> <App /> </BrowserRouter> </React.StrictMode>, document.getElementById('root') ); If we run things locally, everything seems to work. Let's deploy our augmented project to GitHub Pages and see what the result is.
🌐
CodeWalnut
codewalnut.com › learn › how-to-deploy-a-react-application-on-github
How to Deploy a React Application on GitHub | Step-by-Step Guide | CodeWalnut
November 29, 2024 - When you compile a React app, it’s converted into static files that GitHub Pages can effortlessly host. ... In this guide, we’ll go through each step of getting your React application online. We’ll start by setting up your React app, move on to configuring essential fields in package.json, and finally deploy your app so it’s live on GitHub Pages.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › deployment-of-react-application-using-github-pages
Deployment of React Application using GitHub Pages - GeeksforGeeks
In this article, we will walk you through the steps to deploy your React app, making it accessible to users with a live URL. ... GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, optionally runs the files through a ...
Published   July 23, 2025
Top answer
1 of 1
18

To use React on GitHub Pages, you'll need to follow these steps:

Create a new repository on GitHub: Go to GitHub and create a new repository for your React project.

Set up your local development environment: Make sure you have Node.js and npm (Node Package Manager) installed on your computer. You can download them from the official Node.js website if you don't have them already.

Create a new React app: Open your terminal or command prompt and navigate to the directory where you want to create your React app. Run the following command to create a new React app:

npx create-react-app my-app
This will create a new directory called my-app with a basic React project structure.

Build your React app: Once the app is created, navigate into the project directory by running cd my-app. Then, run the following command to build your React app:

npm run build
This will create an optimized production build of your React app in the build directory.

Deploy to GitHub Pages: Install the gh-pages package, which will help you deploy your React app to GitHub Pages. Run the following command:

npm install gh-pages --save-dev
Configure your package.json file: Open the package.json file in your project directory and add the following properties at the top level:

"homepage": "https://your-username.github.io/your-repo-name",
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}
Replace your-username with your GitHub username and your-repo-name with the name of your repository.

Deploy your app: In your terminal or command prompt, run the following command to deploy your React app to GitHub Pages:

npm run deploy
This will create a new branch called gh-pages in your repository and push the built files from the build directory to that branch.

Enable GitHub Pages: Go to your repository on GitHub and navigate to the "Settings" tab. Scroll down to the "GitHub Pages" section and select the gh-pages branch as the source for your GitHub Pages site.

Access your deployed app: After a few moments, your React app should be deployed and accessible at the URL mentioned in the "GitHub Pages" section of your repository settings.

That's it! Your React app is now deployed on GitHub Pages. Anytime you make changes to your app, repeat steps 4 and 7 to rebuild and redeploy your app.

Hope you got your answer.

🌐
GitHub
gist.github.com › Swarag-N › 31a890330269c8ffd68cd4440ad4dacb
Deploy React App to GitHub Pages.md · GitHub
$ sed -i '5i\ "homepage": ... empty Git repository in C:/path/to/react-gh-pages/.git/ Add the GitHub repository as a "remote" in your local git repository....
🌐
LogRocket
blog.logrocket.com › home › 9 ways to deploy a react app for free
9 ways to deploy a React app for free - LogRocket Blog
October 28, 2024 - Before you deploy, make sure your project is stored in a Git repository, and then move on to creating an account on Render. ... Connect your GitHub or GitLab account. Once connected, search for your project repository and select it.
🌐
GitHub
github.com › marketplace › actions › build-and-deploy-react-app-to-github-pages
Build and Deploy React app to GitHub Pages - GitHub Marketplace
Add this action inside your App Repository's Actions · name: Build and Deploy on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Build and Deploy React app to GitHub Pages uses: omkartapale/react-deployment-gh-pages@v1.0.0
🌐
Medium
medium.com › @amh03160 › deploying-a-react-app-on-github-pages-with-a-custom-url-fee94f3be82c
Deploying a React App on Github Pages With a Custom URL | by Allison Hill | Medium
April 22, 2022 - Create a git repository from your online github account and clone it to your machine. I recommend creating the repository directly from a CLI terminal within your react app folder, so that you don’t accidentally end up accidentally nesting ...
🌐
Curotec
curotec.com › home › insights › from local to live: how to deploy your react application
From Local to Live: How to Deploy Your React Application - Curotec
October 1, 2024 - Deploy: Once everything’s set, hit the deploy button. Netlify will build your app and push it live. Create an account: Sign up for Vercel and connect your GitHub, GitLab, or Bitbucket account.
🌐
Pluralsight
pluralsight.com › tech insights & how-to guides › tech guides & tutorials
How to Create a React Application and Deploy It on GitHub Pages | Pluralsight
August 29, 2019 - So every time you need to push static resources (HTML, CSS, and JS) on this branch, they will automatically be deployed and accessible on https://yourusername.github.io/yourprojectname. In order to build your React application and generate static resources that are ready to be deployed from it, create-react-app CLI automatically created a build script in your package.json file.
🌐
DEV Community
dev.to › kathryngrayson › deploying-your-cra-react-app-on-github-pages-2614
Deploying Your CRA React App on Github Pages - DEV Community
July 25, 2022 - A walkthrough (plus troubleshooting for some common issues) for using Github Pages to host your React app.. Tagged with react, javascript, tutorial, beginners.
🌐
Medium
yumingchang1991.medium.com › deploy-simple-react-app-on-github-page-using-npm-in-six-steps-96d5aab76ed6
Deploy Simple React App on Github Page Using NPM in Six Steps | by Yu-Ming, CHANG (he/him) | Medium
June 5, 2022 - For details, you may refer to the reference link below: // install creat-react-app if it is the first time to use it npm install -g create-react-app// run command below to execute create-react-app // personal-portfolio is the name of the new ...
🌐
Zipy
zipy.ai › blog › deploy-react-app-for-free
11 Free Ways to Deploy React Apps [Quick Guide 2025]
September 4, 2025 - Here's how you can proceed to make your React app live using GitHub Pages: • Use these commands in the project root to set up your local directory as a Git repository, commit all code changes, and push your project ...