Deploying React App on GitHub

Rahul Srivastava
2 min readJan 18, 2022

Here, I am going to discuss the steps to deploy your static react app on GitHub.

I am assuming you have a GitHub account, if not kindly create first, and also Git should be installed on your computer. So, Let’s Start. :)

Step 1: Create a repository in GitHub manually.

Step 2: Copy the link you should see after creating the repo. The link should be something like, “ git remote add origin [YOUR REPO LINK] ”.

Step 3: Open Git Bash in a location where you have your projects, and paste the link just you got from your repository.

Step 4: After this, run “ git add . ”, this command will add all files to the staging area.

Step 5: After this, run “ git commit -m “Initial commit” ”, this command will commit your all files.

Step 6: After this, “ git push -u origin main ”, this command will push all codes in GitHub.

Step 7: Now, open the project in any editor locally and open package.json and on the top add this “homepage”: “https://[USERNAME].github.io/[YOUR REPO NAME]”,

Step 8: Now open a terminal and run “ npm install gh-pages — save-dev ”

Step 9: Now add these two lines in package.json in the scripts section

“predeploy”: “npm run build”,

“deploy”: “gh-pages -d build”,

Step 10: now run “ npm run deploy ”, if you will get an error then first run this command “ npm install react-scripts — save ” and then run the above command.

Step11: Now you can go to your website using the link that you set in package.json on top:- homepage one.

Thank you!

If you have any issue kindly reach to me on Rahul Srivastava.

Keep developing!

--

--

Rahul Srivastava
0 Followers

A professional developer currently exploring the technologies.