Deploying a React app means building static assets (HTML, CSS, JS) and serving them. Vercel and Netlify offer one-click deploys from Git. Docker containerizes the app for any cloud. Traditional hosting needs a web server configured for SPAs.
Run the production build to generate optimized static files. npm run build # Output goes to the build/ or dist/ directory The build process minifies code, optimizes images, and generates hashed filenames for caching.
Connect your Git repository to Vercel. It auto-detects React, runs the build, and deploys. npx vercel # Or connect via vercel.com dashboard Vercel handles HTTPS, CDN, and SPA routing automatically.
Connect Git repo to Netlify. Set build command to npm run build and publish directory to build/. Netlify also handles form submissions, serverless functions, and redirects via a _redirects file: /* /index.html 200
Create a multi-stage Dockerfile for production. FROM node:20-alpine AS build WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build FROM nginx:alpine COPY --from=build /app/build /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]