How to Deploy a React App to Production in 2026: Complete Guide
Meta description: Step-by-step guide to deploy a React app to production in 2026. Covers Vercel, VPS, Docker, CI/CD, SSL, monitoring, and performance optimization. Keywords: deploy react app production 2026, react deployment guide, react docker deploy, react vps setup, react ci/cd pipelineYou've built your React app. It works on localhost. Now what? Deploying to production involves more than just npm run build. You need HTTPS, a CDN, proper caching, error monitoring, and a deployment pipeline that won't break at 2 AM.
This guide covers every option — from one-click deploys to full VPS setups with Docker.
Option 1: Vercel (Fastest — 5 Minutes)
Vercel is the path of least resistance for React apps. It's made by the Next.js team and handles everything automatically.
Steps:
That's it. You get:
- Automatic HTTPS
- Global CDN (edge network)
- Preview deploys on every pull request
- Automatic cache invalidation
- Custom domain support
When to use Vercel:
- Side projects and MVPs
- Static sites and SPAs
- When you don't need backend control
When NOT to use Vercel:
- You need a custom backend on the same server
- You want to avoid vendor lock-in
- Your app requires WebSocket connections or long-running processes
Option 2: VPS with Docker (Full Control)
For serious production apps, a VPS gives you complete control over your infrastructure.
Prerequisites:
- A VPS (Hetzner, DigitalOcean, or OVH — €5-20/month)
- A domain name
- Basic command line knowledge
Step 1: Dockerfile
# Build stage
FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
Production stage
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Step 2: Nginx Configuration
server {
listen 80;
server_name yourdomain.com;
root /usr/share/nginx/html;
index index.html;
# React Router support — serve index.html for all routes
location / {
try_files $uri $uri/ /index.html;
}
# Cache static assets aggressively
location /assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# Gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml;
gzip_min_length 1000;
}
Step 3: Docker Compose
version: '3.9'
services:
frontend:
build: .
ports:
- "80:80"
- "443:443"
restart: unless-stopped
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
Step 4: Deploy
# On your VPS
git clone your-repo
cd your-repo
docker compose up -d --build
Step 5: SSL with Certbot
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com
Done. Your React app is live with HTTPS.
Option 3: CI/CD Pipeline (Professional Setup)
For teams, you need automated deployments. Here's a GitHub Actions workflow:
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npm test
- name: Deploy to VPS
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /opt/myapp
git pull
docker compose up -d --build
Every push to main automatically builds, tests, and deploys your app.
Performance Optimization Checklist
Before going live, make sure you've done these:
Build Optimization
- [ ] Enable code splitting with
React.lazy()andSuspense - [ ] Tree-shake unused imports
- [ ] Use production build (
NODE_ENV=production) - [ ] Analyze bundle size with
npm run build -- --stats
Runtime Performance
- [ ] Use
React.memo()for expensive components - [ ] Implement virtual scrolling for long lists
- [ ] Lazy load images with
loading="lazy" - [ ] Preload critical resources with
SEO & Core Web Vitals
- [ ] Add meta tags (title, description, OG tags)
- [ ] Implement server-side rendering or pre-rendering if needed
- [ ] Optimize Largest Contentful Paint (LCP < 2.5s)
- [ ] Minimize Cumulative Layout Shift (CLS < 0.1)
- [ ] Reduce First Input Delay (FID < 100ms)
Monitoring
- [ ] Set up error tracking (Sentry)
- [ ] Add performance monitoring
- [ ] Configure uptime monitoring
- [ ] Set up log aggregation
Common Deployment Mistakes
index.html for all routes, or users get 404s on page refresh.REACT_APP_* variables are baked in at build time. Make sure they're set in your CI/CD pipeline, not just locally.The Fast Path
If you want to skip all this infrastructure work and start with a production-ready React + Symfony SaaS boilerplate that includes Docker, CI/CD, monitoring, and deployment configs out of the box — check out Quernel Cloud Templates.
The SaaS Boilerplate (149€) includes everything in this guide, pre-configured and tested. One-time payment, full source code, deploy in a day.
Get the templates — Stop configuring, start shipping.Published on templates.quernel-cloud.com — Dev Templates for Modern Developers