Deployment
โš›๏ธ React 18+ ๐ŸŸข Chapter 39 of 39 ๐Ÿ“‚ Phase 17: Production and Deployment ๐Ÿ“… 2026 Edition
๐Ÿ“Œ Covered in this chapter: Deploying a Static React App ยท Hosting Options ยท Domain Connection ยท HTTPS ยท Backend API Deployment ยท CI/CD Basics ยท Production Checklist
The final chapter: taking your production build from Chapter 38 and actually putting it online for real users to access.
1Deploying a Static React App
๐Ÿ’ป Example 1: Deploying to a Static Host
Terminal
npm run build
# Deploy the resulting dist/ folder to a static host (Vercel, Netlify, GitHub Pages, etc.)

Since a React app built with Vite compiles down to plain HTML, CSS, and JavaScript files inside dist/, it can be hosted by any static hosting provider โ€” no special server-side runtime is needed for the frontend itself. Popular options (Vercel, Netlify, GitHub Pages, Cloudflare Pages) all offer generous free tiers well-suited to personal and small projects.

2Handling SPA Routing on Deployment

Recall Chapter 26's React Router: URLs like /dashboard only exist inside your single-page app's JavaScript โ€” there's no actual dashboard.html file on the server. Visiting that URL directly (rather than navigating there from within the app) causes a 404 unless the host is configured to redirect all unknown routes back to index.html, letting React Router take over from there:

// Example: Netlify's _redirects file
/*    /index.html   200
3Domain Connection and HTTPS

Most static hosts let you connect a custom domain (like www.myapp.com) by adding DNS records pointing to their servers, and automatically issue a free HTTPS certificate (via Let's Encrypt) once that's configured โ€” HTTPS is essentially mandatory today, both for user trust and because many browser APIs (like geolocation) simply refuse to work on insecure http:// connections.

4Backend Deployment and CI/CD Basics

If your app also has a backend (from JDBC/database work, or a custom API), that typically needs a different kind of hosting that can run a server process continuously (like Railway, Render, or a cloud VM), separate from your static frontend. CI/CD (Continuous Integration/Continuous Deployment) automates this whole process โ€” a GitHub Actions workflow, for example, can automatically run your tests (Chapter 34) and deploy a new build every time you push to your main branch, removing manual deployment steps entirely.

git push โ†’ CI runs tests โ†’ tests pass โ†’ build production bundle โ†’ deploy automatically
โš ๏ธ Deploying Without Configuring SPA Fallback Routing

This is one of the most common first-deployment surprises: your app works perfectly when you navigate through it normally, but refreshing the page on any route other than / shows a 404 error. Configuring your host's fallback/redirect rule (as shown above) to serve index.html for all unmatched routes fixes this immediately.

๐Ÿ’ป Hands-on Interactive Practice Challenge

Write out (in comments) a basic production deployment checklist covering environment variables, the production build command, and SPA routing configuration.

React Practice Challenge โ–ถ Run in Compiler
// Production deployment checklist:
// 1. Set production environment variables (API URLs, keys) on the hosting platform
// 2. Run `npm run build` to generate the optimized dist/ folder
// 3. Configure SPA fallback routing (redirect all routes to index.html)
// 4. Connect custom domain and verify HTTPS is active
// 5. Test the live site directly by refreshing on a non-home route
// 6. Set up CI/CD so future pushes deploy automatically
Run This Challenge in Online JS IDE โ†’
โ“ Frequently Asked Questions (FAQ)

Q Do I need a paid hosting plan to deploy a React app?

Not for learning or small personal projects โ€” Vercel, Netlify, and GitHub Pages all offer free tiers that comfortably handle a static React frontend. Paid plans typically become relevant for higher traffic, custom server needs, or team collaboration features.

Q What's the difference between deploying the frontend and deploying the backend?

The React frontend (after npm run build) is just static files servable by any static host. A backend (like a JDBC-connected API server) needs to run continuously as a live process, requiring a different kind of hosting that supports long-running server applications, not just static file serving.

OC
Written by Our Compiler Technical Editorial Team
Reviewed for accuracy & tested on React 18+ ยท Last updated August 2026