Host your react app with Github

Host your react app with Github

Here I assume that you have knowledge about pushing your code to the github or else you can refer this article by Datacamp about pushing your code to github. Every command should be executed in your project directory. Please follow this step by step process.

At first push your code to github and then Add the URL to the package.json file. key will be 'homepage' and url will be appropriate to your github respository as shown below.

  "homepage": "https://psp3075.github.io/quiz",
  "name": "quiztime",
  "version": "xxxx",
  "private": true,
  • psp3075 - Github Username
  • quiz - Github Repository
  • Install gh-pages

    npm install gh-pages

    Add scripts as shown below, in the package.json file

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

    After all these tasks, there is only 1 command left to publish your site. i.e,

    npm run build

    Congrats, you just deployed your react application to github pages. Now to check it out, visit the url mentioned in the package.json file and share it with your friends.