How to Deploy your React App to GitHub
After building my react app. I typed run build and then sent the build file to netlify. I thought deploying to GitHub is the same way. Here I will show you hot to deploy your react app to GitHub. The Steps below
1. Create an empty GitHub repository
Create a repository without a README.md file, a .gitignore file, a LICENSE file, or any other files.
2. Create your react app
Create the react app you want to deploy
3. Install gh-pages as a dependency
Install the gh-pages as a dependency of your app.
npm install gh-pages --save-dev
4. Add Properties to package.json file
Add the home page property to the package.json file of your react app. Make sure it is at the top. This will include your GitHub username and the name of the repository you created in step 1.
"homepage": "http://yourgithubusername.github.io/nameofrepository"
Then add a predeploy and deploy property to the existing script property
"scripts": {
//...
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}
5. Create a git repository in the app folder
git init
Initialized empty Git repository in C:/path/to/react-gh-pages/.git/
6. Deploy your app
Deploy your react app to GitHub by running
npm run deploy
And that's it . Your app is now deployed to Github.
If you love my posts, consider following me on twitter. Also don't forget to comment, leave a reaction and share this post. Thanks y'all