GitHub Pages provides a convenient way to showcase and share your React applications with the world. In this guide, we'll walk through the process of deploying a React app to GitHub Pages.
Step 1. Create a GitHub Repository
- Start by creating a new repository on GitHub. You can do this by clicking on the "+" sign near your profile and selecting "New Repository."
- Provide a name for your repository and click "Create repository."
- Initialize the repository by executing the following commands in your VS Code terminal.
Step 2. Add GitHub Pages Dependency
- Install the
gh-pages
dependency using npm.
Step 3. Update package.json
- Open your
package.json
file and add the following properties.
Replace <username>
with your GitHub username and <repo-name>
with the name of your repository.
- Add the following scripts in the
scripts
section.
Step 4. Push Code Updates and Deploy
- Push your code updates to GitHub.
- Deploy the application using the following command:
Step 5. View the Deployed App
- Visit your GitHub repository and navigate to "Settings."
- Under "GitHub Pages," you'll find the link to your deployed React app.
Congratulations! Your React app is now live on GitHub Pages, and you can share the link with others.
By following these steps, you've successfully deployed your React app, making it accessible to a wider audience. Whether it's a personal project or a portfolio piece, GitHub Pages provides a straightforward way to showcase your work.
GitHub Repository Create
![Click new]()
![Create new repository]()
![JSON Code]()
![Command Prompt]()
![Pages]()
![React JS]()