How to deploy a React app to GitHub pages ? , React pages is a free static website hosting by github
1- Create New Repo : Create new github repo , Choose a username & add .github.io
example : yourname.github.io
2 - Install github pages dependency : Install **gh-pages **using the following command
npm install gh-pages — save-dev
3 - Add Deploy & Homepage scripts : Add these two lines of code in your package.json file
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
Add Home Page Prop To The Same File :
"homepage": "https://yourname.github.io",
Note replace your name with your git repo name
4- Deploy Your Static Website : run npm deploy to deploy your website
npm run deploy
Top comments (0)