Skip to content
No results
  • JavaScript Interview Series
  • React Js
    • React Basics
    • React Hooks
  • HTML/CSS
  • Java Script

What About Coding

  • JavaScript Interview Series
  • React Js
    • React Basics
    • React Hooks
  • HTML/CSS
  • Java Script
Book a call @99

What About Coding

Host React Js website live on the internet using github

  • Himanshu ShekharHimanshu Shekhar
  • July 14, 2022
  • React Basics, React Js
  • 7 Comments

Well, hostings is paid, but if you are a developer with technical skills, you can always find a free solution.

So today in this article we will use GIT and our developer skills to host a react js frontend website on Github for absolutely free.

Let’s get started !

Table of Contents

Toggle
    • Watch video instead
  • Step 1 – Setup git in your system
  • Step 2 – Create a repository
  • Step 3 – Push your code from local to git repo
  • Step 4 – Install gh-page and edit package.json file
  • Step 5 – Deploy

Watch video instead

Step 1 – Setup git in your system

  • First, download gitbash on your system, if you haven’t already – Git bash
  • Once downloaded and installed, go to your folder and right click (or shift + right click) , and you will see 2 options
  • Now , got ahead and click on “Git Bash Here”
One command prompt repo might have opened , just minimise it and follow step 2

Step 2 – Create a repository

  • Login to github and sign in/sign up
  • Create a new repository (make sure you keep it public)
  • Once repository is created , go back to you git bash terminal and follow the third steps

Step 3 – Push your code from local to git repo

Open your gitbash terminal at the folder where your code is located.

Start typing the below codes

git init
git add .
git status(check all the files are commited or not)
git commit -m "first commit"
git branch -M main
git remote add origin 'your_url_name'
git push -u origin master

Step 4 – Install gh-page and edit package.json file

  • Install gh-page npm package

Check which one command works.

npm install --save gh-pages
or
npm install gh-pages --save-dev
  • Edit the package.json file and added the below lines

Eg – “homepage” : “https://<username>.github.io/<repo-name>

//After name key-pair value ,
    "homepage": " https://highhimanshu.github.io/demo-crud1",
//Inside script object
    "predeploy" : "npm run build", 
    "deploy": "gh-pages -d build", 

Step 5 – Deploy

Now write the below command to deploy your website to GitHub and create a link

npm run deploy

Once the build is successful, A Link is created automatically, that will be your hosted website link

Go to repo > setting > pages > select gh-pages and save.


Help Others
Previous Post CRUD in React JS using Axios | Building an App using React CRUD
Next Post Full Stack application using Node Js, Express Js, SQL, Bootstrap, and Java Script

Related Posts

Build an AI Content Generator with React ft. Gemini
  • September 22, 2024
Context API in React Js
  • September 14, 2024
React.memo , useMemo() and useCallback() explained
  • August 12, 2024

7 Comments

  1. Himanshu Kashyap

    Himanshu Kashyap

    January 29, 2023 / 1:40 am Reply

    Very informative and to the point! Keep posting informative content. I followed this blog post from your YouTube Channel! Cheers!

    • Himanshu Shekhar

      Himanshu Shekhar

      January 31, 2023 / 4:34 am Reply

      Thanks alot:)

  2. Edua5do Tell

    Edua5do Tell

    March 12, 2023 / 1:56 am Reply

    Something on github must have changed because it doesn’t seem to work anymore

  3. deepika

    deepika

    May 27, 2023 / 11:51 am Reply

    when i use all this commad just navbar run in this code but when you click any navbar it show 404

  4. Addytech

    Addytech

    June 5, 2023 / 7:47 pm Reply

    I followed all steps above but after pusblishing the site and open URL its showing REAME file content not the website

  5. HIMANSHU CHANDRAKUMAR KAPSE

    HIMANSHU CHANDRAKUMAR KAPSE

    September 23, 2023 / 6:25 am Reply

    One of Best Tutorial Ever! Easily understand

  6. Bhavin Borkhataria

    Bhavin Borkhataria

    January 7, 2024 / 12:53 pm Reply

    Hi Himanshu,
    Thank you for posting a very informative post and video. I just published a React math quiz app via Github. I am using React Router 6 and I followed all your steps. I am getting this error message:
    Error with Permissions-Policy header: Origin trial controlled feature not enabled: ‘interest-cohort’.

    A blank webpage is always displayed.
    https://bhavin-rb.github.io/algebra1_quiz/
    https://github.com/bhavin-rb/algebra1_quiz/

    Can you please assist to resolve this problem. Thank you.

Leave a ReplyCancel Reply

Your email address will not be published. Required fields are marked *

No results
preplaced

Latest Posts

redux toolkit himanshu shekhar

Redux Toolkit Tutorial

December 9, 2022

Host React Js website live on the internet using github

July 14, 2022

Build a simple MERN Stack Application | CRUD using

February 24, 2023

Build an app using createAsyncThunk and Redux Toolkit

March 24, 2023

Full Stack application using Node Js, Express Js, SQL, Bootstrap, and Java Script

July 29, 2022

Copyright © 2026 - Developed by Himanshu