A single-page React app plus a Node.js API is one of the most common full-stack setups. It splits neatly into two parts with very different needs: the frontend is static files that any web server can deliver from cache, and the backend is a long-running process that does the real work. Hosting both on one VPS is simple, fast and inexpensive when each part is handled properly.
The Layout
https://app.example.com
├─ / → Nginx serves /srv/web/current/dist (React build)
├─ /assets/* → Nginx, cached for a year (hashed filenames)
└─ /api/* → proxy to Node.js on 127.0.0.1:4000 (one or more processes)
└─ PostgreSQL / MongoDB / Redis on localhost
Serving both on the same domain avoids CORS configuration and cookie issues.
Step 1: Build and Serve the React App
npm ci
npm run build # Vite outputs to dist/
server {
server_name app.example.com;
root /srv/web/current/dist;
location /assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
}
location / {
try_files $uri /index.html; # client-side routing
add_header Cache-Control "no-cache";
}
location /api/ {
proxy_pass http://node_api;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
index.html must not be cached long, so users get new deployments; hashed assets can be cached for a year. Build in CI rather than on the server where possible, and upload the dist folder as a release.
Step 2: Run the Node.js API
# /etc/systemd/system/api@.service
[Unit]
Description=Node API instance %i
After=network.target
[Service]
User=api
WorkingDirectory=/srv/api/current
Environment=NODE_ENV=production
Environment=PORT=400%i
EnvironmentFile=/etc/api/env
ExecStart=/usr/bin/node dist/server.js
Restart=always
RestartSec=3
MemoryMax=1G
[Install]
WantedBy=multi-user.target
sudo systemctl enable --now api@1 api@2 api@3 api@4
upstream node_api {
server 127.0.0.1:4001;
server 127.0.0.1:4002;
server 127.0.0.1:4003;
server 127.0.0.1:4004;
keepalive 32;
}
Node.js runs JavaScript on one thread per process, so several processes use several vCores. PM2's cluster mode (pm2 start dist/server.js -i max) is an alternative with built-in log management and zero-downtime reloads; use pm2 startup so it restarts at boot.
Step 3: Configuration and Secrets
- Read configuration from environment variables; keep
/etc/api/envreadable only by the service user. - Remember that anything in the React build is public: never put API secrets in frontend environment variables (Vite exposes variables prefixed with
VITE_to the browser). - Use the current Node.js LTS release and pin it in
package.jsonengines.
Step 4: Production Settings in the API
- Trust the proxy so client IPs and HTTPS are detected correctly (in Express:
app.set('trust proxy', 'loopback')). - Add security headers (for example with Helmet) and rate limiting on authentication routes.
- Validate input with a schema library; return consistent JSON errors.
- Set timeouts on database and external HTTP calls.
- Handle
SIGTERM: stop accepting connections, finish in-flight requests, close the database pool, exit.
Step 5: Websockets
location /socket.io/ {
proxy_pass http://node_api;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 3600s;
}
With several Node.js processes, websocket libraries need sticky sessions (ip_hash in the upstream, or the library's cluster adapter) and a shared adapter such as Redis so messages reach clients connected to other processes.
Step 6: The Database
Run PostgreSQL, MySQL or MongoDB on localhost, with authentication enabled and no public port. Use a connection pool in the API, sized so total connections across processes stay within the database's limits (see our PostgreSQL guide). Back up off the server.
Step 7: Logs and Monitoring
Log JSON lines with a request ID (pino is fast), read them with journalctl -u 'api@*', and cap the journal size. Track request rate, error rate, p95 latency, event-loop lag and memory per process; alert on restarts and errors (see our monitoring guide).
Step 8: Deploys
- CI runs tests, builds the React app and the API.
- Upload both as new release directories.
- Install production dependencies for the API (
npm ci --omit=dev), run migrations. - Switch symlinks, restart API instances one at a time, check
/api/health.
Restarting instances one at a time behind the Nginx upstream keeps the API available throughout.
Sizing
| Project | EPYC plan |
|---|---|
| React SPA + Express API + database, small team or MVP | 2 vCores / 8 GB |
| Production app with 4 API processes, workers, Redis and database | 4 vCores / 16 GB |
| Busy real-time app with many websocket connections | 8 vCores / 32 GB |
When to Add Server Rendering
A client-rendered React app is simple to host, but search engines and social previews see less content, and the first screen appears only after JavaScript downloads and runs. For public pages that need SEO or fast first paint, consider a framework with server rendering such as Next.js or Remix, or prerender marketing pages at build time. Internal dashboards and tools behind a login usually do not need it (see our Next.js guide).
Keep the Event Loop Free
Because each Node.js process runs JavaScript on one thread, a single CPU-heavy operation, such as resizing an image, parsing a large file or a synchronous crypto call, blocks every other request on that process. Move such work to worker threads or a job queue, use asynchronous APIs, and monitor event-loop lag; rising lag is an early sign that a process is overloaded.
Common Mistakes
- Running the API with
nodein a terminal ornpm startunderscreeninstead of a supervisor. - Serving the React build from Express instead of Nginx.
- Exposing the API port directly to the internet.
- Putting secrets in frontend environment variables.
- Opening a new database connection per request instead of using a pool.
Launch Checklist
- React build served by Nginx with correct caching for HTML and assets.
- API processes supervised, one per vCore, behind an Nginx upstream.
- Secrets only on the server, never in the frontend build.
- Database on localhost with pooled connections and off-site backups.
- Health check, logs and alerts in place before announcing the app.
SkyRainCloud Plans for This Workload
A React build is static and costs almost nothing to serve; size the plan for the Node.js API and database. 2 vCores / 8 GB suits a typical full-stack app; 4 vCores / 16 GB runs several API processes, workers and a database comfortably.
AMD EPYC 7C13 VPS
Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — AMD | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Websites, small APIs, bots, staging and VPN servers | Order |
| VPS 2 — AMD | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,299/month | WooCommerce, Node.js/Python backends, Docker Compose stacks, CI runners | Order |
| VPS 3 — AMD | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,499/month | Production databases, high-traffic sites, multi-container apps | Order |
| VPS 4 — AMD | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,899/month | Large production workloads, SaaS platforms, analytics, in-memory caches | Order |
Prices are monthly in INR as listed on the SkyRainCloud store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.