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
To create the React app, I'll be ... the React app, I'll be using gh-pages, which is an npm package people can use to deploy things to GitHub Pages, a free web hosting service provided by GitHub....
Author: gitname
Top answer
1 of 3
12

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.

Discussions

Deploying react to github pages
If possible could you please check Vercel? Much easier that way. More on reddit.com
🌐 r/react
24
4
July 26, 2023
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
🌐
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.
🌐
Reddit
reddit.com › r/react › deploying react to github pages
r/react on Reddit: Deploying react to github pages
July 26, 2023 -

I have to deploy my React app to github pages. I use React and Coveo Headless library. All my project files are tsx instead of js or jsx. I configured package.json to deploy it on github pages, but it deploys index.html template and loads blank page. Does anyone have idea how to resolve it?

As I am newby for this, I followed this tutorial for deployment, but no success.

https://youtu.be/Q9n2mLqXFpU

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.

🌐
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 - If you don’t, take a look at these guides for using Create React App to spin up a new React project and then pushing that project into a new Github repo. Open up your Github repo and navigate to Settings > Pages.
🌐
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 build process and publishes a website.
Published: July 23, 2025
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › deploy-a-react-app-to-github-pages
How to Deploy a Routed React App to GitHub Pages
February 22, 2021 - So before we move on, we must have our project uploaded there. Head over to your GitHub account and create a repository with the same name as the React project. ☝️ Make sure to mark your repository as public.
🌐
GeeksforGeeks
geeksforgeeks.org › gblog › how-to-deploy-your-react-websites-on-github
How to Deploy Your React Websites on GitHub? - GeeksforGeeks
July 12, 2025 - Follow the command below and generate a production build of your app, to deploy your code on GitHub pages. ... That's it. Your React application is published on GitHub pages and if you want to verify it just go to the settings tab of your ...
🌐
GitHub
github.com › marketplace › actions › deploy-react-to-github-pages
Deploy React to GitHub Pages · Actions · GitHub Marketplace
This action uses the new GitHub Actions publishing method which allows you to create an artifact that contains the result of the build and serves the files in the artifact on the Pages site. There’s no need to check files back into your repository, keeping it nice and clean. This action deploys React/Javascript to Github Pages.
🌐
GeekyAnts Tech Blog
techblog.geekyants.com › deploying-the-react-app-on-github-pages
Deploying the React App on GitHub Pages
July 9, 2021 - The application is hosted in a sub directory; which means we can deploy multiple applications in different sub directories on our GitHub Pages URL, as long as it doesn't hit the cap. It is also very helpful to setup custom 404 pages.
🌐
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 - One of these options ended up being right under my nose the whole time- Github Pages! All you need to do is have a github repository for the project, tell github which branch to publish from, and voila! 95% of the work is already done for you!
🌐
Create React App
create-react-app.dev › docs › deployment
Deployment | Create React App
You can configure a custom domain with GitHub Pages by adding a CNAME file to the public/ folder.
🌐
GitHub
github.com › marketplace › actions › build-and-deploy-react-app-to-github-pages
Build and Deploy React app to GitHub Pages - GitHub Marketplace
Set your source branch for GitHub Pages (Example: gh-pages) in Settings -> Pages section · 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
🌐
Pluralsight
pluralsight.com › blog › tech guides & tutorials
Deploying React on Github Pages | Pluralsight
July 10, 2020 - "scripts": { "start": "react-scripts start", "build": "react-scripts build", #new "predeploy": "yarn run build", "deploy": "gh-pages -b master -d build", "test": "react-scripts test", "deploy": "gh-pages -b master -d build", "eject": "react-scripts eject" }, Whew! That's it. You should now be able to deploy any React app to Github Pages anytime you want.
🌐
Medium
medium.com › @swarajgosavi20 › how-to-deploy-react-on-github-pages-33e427f0bd36
How to Deploy React on GitHub Pages? | by Swaraj Gosavi | Medium
July 19, 2023 - Set the repository as public this will allow us to use GitHub pages. Let's link our local folder with GitHub by running the following commands in the terminal. Replace myusername with your GitHub username. git commit -m "initial commit" git ...
🌐
LinkedIn
linkedin.com › pulse › deploy-your-react-app-using-github-pages-hasibul-islam
Deploy your React app using GitHub pages
June 22, 2023 - Run the following commands to push your changes to the remote repository. git add . git commit -m "your commit message" git push origin main · Deploying your React app to GitHub Pages is a simple and easy way to share your app with the world.
🌐
Educative
educative.io › answers › how-to-deploy-a-react-app-on-github-pages
How to deploy a React app on GitHub pages
Create a public GitHub repository for your React app. You need to create a GitHub account if you haven’t already. Make a note of your owner and repository name in GitHub. ... and make a new key named homepage, and make its value something ...