Deploy a React Static App
Deploy your React SPA to a global HTTPS URL — no hosting config.
Overview
React single-page applications compiled with Vite or Create React App produce a static `dist/` folder that can be served from any nginx or static file server. Kubeletto auto-generates a production-ready nginx container from your build output.
Prerequisites
- A React project with a build script (npm run build)
- Output goes to dist/ (Vite) or build/ (CRA)
- A Kubeletto account
Step-by-Step Guide
Deploying React + Vite / CRA to Kubeletto is done by configuring a Dockerfile, connecting your GitHub repository, and setting environment variables. Follow this step-by-step checklist to deploy your code:
- 1
Create a Dockerfile for the static build
Build your React app and serve it with nginx in a single multi-stage Dockerfile.
dockerfileFROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build FROM nginx:alpine COPY --from=builder /app/dist /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] - 2
Add an nginx.conf for SPA routing
React Router requires all paths to serve index.html.
nginxserver { listen 80; root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; } } - 3
Deploy
Push to GitHub or deploy from CLI. Kubeletto builds the container and serves your app.
bashkubeletto deploy --source github --repo your-org/react-app --branch main
Sample Environment Variables
To configure your React + Vite / CRA application, set these key-value pairs in the environment variables tab of the Kubeletto console or CLI. Ensure production secrets are flagged as write-only:
VITE_API_URL=https://your-api.kubeletto.app
VITE_SENTRY_DSN=https://... Related Kubeletto Features
Kubeletto offers automatic SSL certificate provisioning, zero-downtime rollbacks, and scale-to-zero autoscaling for React + Vite / CRA container workloads:
PaaS Platform Comparisons
See how Kubeletto compares directly against other cloud platforms and PaaS providers when deploying TypeScript / JavaScript workloads:
Frequently Asked Questions
Find direct answers to common questions about hosting, building, scaling, and managing React + Vite / CRA containerized apps on Kubeletto:
Can I inject environment variables at build time for Vite?
Yes. Set VITE_* variables in Kubeletto before triggering a build. They are injected during the docker build step and bundled into the static output.
Does Kubeletto support React Router v6 / v7?
Yes. The nginx try_files pattern in the guide above handles all React Router paths correctly.
Should I use React static or Next.js for SEO-sensitive pages?
For SEO-critical content, use Next.js with SSR or static generation. React SPAs are not indexed well by search engines without pre-rendering.
Deploy your React + Vite / CRA app today
Free during our active beta. No credit card required.
Start Deploying Free