Logo

dev-resources.site

for different kinds of informations.

Free Hosting Using Github pages

Published at
9/4/2024
Categories
github
hosting
Author
ram_ram007
Categories
2 categories in total
github
open
hosting
open
Author
10 person written this
ram_ram007
open
Free Hosting Using Github pages

Hosting a React App on GitHub Pages

In this guide, I'll walk you through the steps to host your React app on GitHub Pages.

Step 1: Create a GitHub Repository

  1. Go to GitHub and create a new repository.
  2. Name the repository (e.g., my-react-app).
  3. Optionally, initialize the repository with a README.md file.

Step 2: Install gh-pages

Navigate to your React app's directory and install the gh-pages package:

npm install gh-pages --save-dev
Enter fullscreen mode Exit fullscreen mode

Step 3: Update package.json

Open your package.json file and make the following changes:

Add a homepage Field

At the top of your package.json, add:

"homepage": "https://<your-username>.github.io<your-repository-name>"
Enter fullscreen mode Exit fullscreen mode

Replace <your-username> with your GitHub username and <your-repository-name> with the name of your repository.

Add Deployment Scripts

Add the following scripts to the scripts section of package.json:

"scripts": {
  "predeploy": "npm run build",
  "deploy": "gh-pages -d build"
}
Enter fullscreen mode Exit fullscreen mode
  • predeploy: Automatically runs npm run build before deploying.
  • deploy: Deploys the contents of the build directory to the gh-pages branch.

Step 4: Build and Deploy

Run the following command to build and deploy your app:

npm run deploy
Enter fullscreen mode Exit fullscreen mode

This command creates a production build of your app and pushes it to a gh-pages branch in your repository.

Step 5: Configure GitHub Pages

  1. Go to your repository on GitHub.
  2. Click on the "Settings" tab.
  3. Scroll down to the "GitHub Pages" section.
  4. Under "Branch," select gh-pages.

Your React app should now be live on GitHub Pages at https://<your-username>.github.io/<your-repository-name>.


hosting Article's
30 articles in total
Favicon
How to run your website for Free ?
Favicon
What is Web Hosting and How Does It Work?
Favicon
Different Types of Web Hosting Explained
Favicon
Skycloak
Favicon
Hostinger Review 2025: Speed, Performance & Value for Money
Favicon
How I built my own managed hosting platform
Favicon
ProHoster.info: The Ultimate Solution for Reliable and Affordable Web Hosting
Favicon
Linux Shared Hosting: Balancing Performance, Security, and Cost
Favicon
A $5 to $10 VPS can do a lot more than you think
Favicon
How to Optimize Vercel Costs
Favicon
Best Hosting Provider : Accuwebhosting
Favicon
Why VPS Hosting is the Future of Small Business Websites in 2024–2025
Favicon
Step-by-Step Guide to Hosting Your Website on a VPS Using Caddy Server and Cloudflare
Favicon
Trick or Treat Yourself to 20% OFF Web Hosting – bodHOST Halloween Sale
Favicon
Ayuda por favor!
Favicon
How to host Browser.application projects
Favicon
10 Free Web Hosting Solutions for Static and Dynamic Sites
Favicon
How I host Elm web applications with GitHub Pages
Favicon
Can You Really Host Laravel on Shared Hosting?
Favicon
Best Web Hosting and Domain Providers in UAE: A Complete Guide
Favicon
Newt Labs - WordPress Site Care from £79 per month
Favicon
Hosting Web Application For The Web
Favicon
Free Hosting Using Github pages
Favicon
Connect Namecheap Domain to KnownHost
Favicon
Deploy Laravel Projects to Namecheap Server on Github Push with 3 Easy Steps (The only tutorial you would every need)
Favicon
WP Raptor Host Review – Unlimited WP Sites, Access for Life
Favicon
Detailed Guide: Choosing the Right WooCommerce Hosting
Favicon
Why do I need a professional email?
Favicon
The Ultimate Guide to Choosing the Best Web Hosting for WordPress in 2025
Favicon
How to Send Emails Using Gmail SMTP with Cloudflare Email Routing?

Featured ones: