Starts a production HTTP server to serve the output fromDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/cloudflare/vinext/llms.txt
Use this file to discover all available pages before exploring further.
vinext build. Supports SSR, static file serving, compression, and middleware.
Usage
Options
Port to listen on. Can also use the short form
-p. Defaults to the PORT environment variable if set.Hostname to bind to. Can also use the short form
-H.Default is
0.0.0.0 (all interfaces) in production, unlike dev mode which defaults to localhost.Show help for this command. Can also use
-h.Behavior
Server Implementation
The production server is implemented inserver/prod-server.ts and provides:
- Static asset serving: Serves files from
dist/client/ - SSR rendering: Server-side renders pages on request
- API route handling: Routes
/api/*requests to server handlers - Compression: Gzip and Brotli compression for text-based responses
- Streaming SSR: Supports React 18 streaming for App Router
Request Handling
The production server handles requests in this order:- Middleware/Proxy (if exists)
- Redirects (from
next.config) - Rewrites (from
next.config) - Static assets (
dist/client/) - API routes (
/api/*) - Page routes (SSR)
- 404 page (if no match)
Response Compression
The server automatically compresses responses:SSR Output
For Pages Router, the server loads the SSR entry:Examples
Basic Usage
Start production server on default port (3000):Custom Port
Start on port 8080:Using Environment Variables
.env.production:
Bind to Localhost Only
For security on shared hosts:Production npm Script
Add topackage.json:
Deployment
Node.js Deployment
For traditional Node.js hosting:Docker Deployment
Cloudflare Workers
For Cloudflare Workers, usevinext deploy instead:
Process Management
Using PM2
For production deployments with auto-restart:Using systemd
Create/etc/systemd/system/my-app.service:
Performance
Response Times
Typical server response times:| Route Type | Cold Start | Warm |
|---|---|---|
| Static asset | less than 1ms | less than 1ms |
| SSR page (cached) | 5-15ms | 2-5ms |
| SSR page (fresh) | 20-50ms | 10-20ms |
| API route | 5-20ms | 2-10ms |
Benchmarks from a medium-complexity app on modern hardware. Actual times vary by complexity.
Compression Impact
Typical compression ratios:| Content Type | Original | Gzip | Brotli |
|---|---|---|---|
| HTML | 100KB | 20KB (80%) | 18KB (82%) |
| JavaScript | 500KB | 150KB (70%) | 130KB (74%) |
| CSS | 50KB | 12KB (76%) | 10KB (80%) |
| JSON | 100KB | 10KB (90%) | 8KB (92%) |
Caching Strategy
The server sets these cache headers:Troubleshooting
”dist/ directory not found”
You forgot to build first:Port Already in Use
Another process is using the port:Pages Not Loading (404)
Check the build output:High Memory Usage
The server loads all pages into memory. For very large apps:-
Increase Node.js heap size:
-
Or deploy to Cloudflare Workers (no memory limits):
Monitoring
Health Check Endpoint
Add a health check page:Access Logs
The production server logs all requests to stdout:Next Steps
deploy Command
Deploy to Cloudflare Workers
Deployment Guide
Learn about deployment options