Deployment of React Application using GitHub Pages
Last Updated :
23 Jul, 2025
Deploying a React application using GitHub Pages is an easy and efficient way to host your projects online for free. In this article, we will walk you through the steps to deploy your React app, making it accessible to users with a live URL.
Prerequisites
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.
Why Use GitHub Pages for Deployment?
- Free Hosting: GitHub Pages offers free hosting for static websites, making it an ideal choice for deploying React applications.
- Easy Integration: Seamlessly integrate your GitHub repository with GitHub Pages.
- Automatic Updates: Automatically update your live site by pushing changes to your repository.
How to Deploy A React app?
Step 1. Create the GitHub repository first by doing the following steps:
Click on the + sign near the profile and click on the New Repository.
.png)
Giving the name to the Repository.
.png)
Clicking on the Create repository and executing the following commands which will be shown just after clicking on the create repository on your VS code terminal.
git init
git add .
git commit -m "first commit"
git branch -M main
And then enter the following command in which we have to replace the <username> with the username of your GitHub account and the <rep Name> with the name of the repository which you have created.
git remote add origin https://github.com/<username>/<rep Name>.git
For example, git remote add origin https://github.com/vishalWaghmode/TextEdit
And, then enter the following commands which will push the react application to the above repository
git push -u origin main
And, then refresh the GitHub site and you will get to see the uploaded code.
Step 2. Adding the GitHub Pages dependency packages
The gh-pages package allows us to publish the build file of our application into a gh-pages branch on GitHub, where we are going to host our application. Install the gh-pages dependency using npm :
npm install gh-pages --save-dev
Step 3. Adding the properties to the package.json file
The package.json file is been configured so that we can point the GitHub repository to where our react app is been deployed. The first property we have to add is at the top of the package.json file which will be given the name "homepage", and the value for it will be in the following format:
"homepage": "https://<Username>.github.io/<Repository-name>"
Example: "homepage": "https://vishalwaghmode.github.io/Textutil"
Then we will add "deploy" and "predeploy "properties in the script field with the following values:
"scripts":{
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}
.png)
Step 4. Pushing the code updates to the GitHub repository and finally deploying the application
For pushing the updates which we have done in the code we can use the following commands:
git add .
git commit -m "commit"
git push
And now finally deploy the application using the following command in the terminal:
npm run deploy
This command will publish your application on the branch named gh-pages and can be opened by the link given in the homepage property written in the package.json file.
Step 5. View the deployed app on GitHub
Now, to view the link for opening the application we will go on the GitHub and click on Settings then at the left of the settings we can see the code and automation where the pages field will be present, just clicking it we will get the following interface where the link will be provided.

Note: If the link does not come then just wait for 2-3 minutes and then again refresh the browser and then click on the link again on it.
Tips for Managing Your Deployment
- Automatic Deployment: Set up a GitHub Actions workflow to automate the deployment process every time you push changes to the main branch.
- Custom Domain: Use a custom domain by adding a
CNAME
file to the public
folder with your custom domain name. - Branch Management: Ensure that the
gh-pages
branch is protected or managed properly to prevent unintended deletions or modifications.
Deployment of React Application using GitHub Pages
Similar Reads
React Tutorial React is a powerful JavaScript library for building fast, scalable front-end applications. Created by Facebook, it's known for its component-based structure, single-page applications (SPAs), and virtual DOM,enabling efficient UI updates and a seamless user experience.Note: The latest stable version
7 min read
React Fundamentals
React IntroductionReactJS is a component-based JavaScript library used to build dynamic and interactive user interfaces. It simplifies the creation of single-page applications (SPAs) with a focus on performance and maintainability. "Hello, World!" Program in ReactJavaScriptimport React from 'react'; function App() {
6 min read
React Environment SetupTo run any React application, we need to first setup a ReactJS Development Environment. In this article, we will show you a step-by-step guide to installing and configuring a working React development environment.Pre-requisite:We must have Nodejs installed on our PC. So, the very first step will be
3 min read
React JS ReactDOMReactDOM is a core React package that provides DOM-specific methods to interact with and manipulate the Document Object Model (DOM), enabling efficient rendering and management of web page elements. ReactDOM is used for: Rendering Components: Displays React components in the DOM.DOM Manipulation: Al
2 min read
React JSXJSX stands for JavaScript XML, and it is a special syntax used in React to simplify building user interfaces. JSX allows you to write HTML-like code directly inside JavaScript, enabling you to create UI components more efficiently. Although JSX looks like regular HTML, itâs actually a syntax extensi
5 min read
ReactJS Rendering ElementsIn this article we will learn about rendering elements in ReactJS, updating the rendered elements and will also discuss about how efficiently the elements are rendered.What are React Elements?React elements are the smallest building blocks of a React application. They are different from DOM elements
3 min read
React ListsIn lists, React makes it easier to render multiple elements dynamically from arrays or objects, ensuring efficient and reusable code. Since nearly 85% of React projects involve displaying data collectionsâlike user profiles, product catalogs, or tasksâunderstanding how to work with lists.To render a
4 min read
React FormsIn React, forms are used to take input from users, like text, numbers, or selections. They work just like HTML forms but are often controlled by React state so you can easily track and update the input values.Example:JavaScriptimport React, { useState } from 'react'; function MyForm() { const [name,
4 min read
ReactJS KeysA key serves as a unique identifier in React, helping to track which items in a list have changed, been updated, or removed. It is particularly useful when dynamically creating components or when users modify the list. When rendering a list, you need to assign a unique key prop to each element in th
4 min read
Components in React
React Lifecycle In React, the lifecycle refers to the various stages a component goes through. These stages allow developers to run specific code at key moments, such as when the component is created, updated, or removed. By understanding the React lifecycle, you can better manage resources, side effects, and perfo
7 min read
React Hooks
Routing in React
Advanced React Concepts
React Projects