How to build and deploy a React app to Github pages in less than 5 minutes

Understanding React deployment

Choosing the correct server

Prerequisite:

Getting Started

Deployment

Step 1: Install the gh-pages package as a “dev-dependency” of the app

Step 2: Add homepage property to package.json file

package.json file after adding the homepage property

Step 3: Deploy scripts under package.json file

“scripts”:{
...
"predeploy": "yarn run build",
"deploy": "gh-pages -d build",
...
}
package.json script object after deploying scripts

Step 4: Create a remote GitHub repository

Step 5: Now deploy it to GitHub Pages

Terminal screenshot while deployment

Step 6: Update your repository code (optional)

git add .
git commit -m “Your commit message”
git push origin master

Note:

Experience with Front-end Technologies and MERN / MEAN Stack. Working on all Major UI Frameworks like React, Angular.