Deployment
TanStack Start applications can be deployed to various platforms including Cloudflare Workers, Vercel, Netlify, and traditional Node.js servers. This guide covers deployment strategies for different platforms.Build Process
Before deployment, build your application for production:dist directory.
Cloudflare Workers
Deploy to Cloudflare’s edge network for global, low-latency serving.Environment Variables
Set environment variables in Wrangler:Cloudflare Bindings
Access Cloudflare services (KV, D1, R2) in your app:wrangler.jsonc:
Vercel
Deploy to Vercel’s edge and serverless infrastructure.Install Vercel CLI
Environment Variables
Set environment variables in Vercel Dashboard or CLI:Edge Functions
Optimize for edge deployment:Netlify
Deploy to Netlify’s edge and serverless platform.Install Netlify CLI
Environment Variables
Set environment variables in Netlify Dashboard or CLI:Node.js Server
Deploy to any Node.js hosting provider (AWS, DigitalOcean, Railway, etc.).Docker Deployment
Create aDockerfile:
Static Export
Generate a static site for deployment to static hosts (GitHub Pages, S3, etc.).Dynamic Route Prerendering
Prerender dynamic routes:CDN Configuration
Optimize asset delivery with CDN URL rewriting:Per-Request CDN URLs
Generate CDN URLs per request:Environment-Specific Configuration
Handle different environments:Health Checks
Implement health check endpoints:Monitoring and Logging
Implement request logging:Performance Optimization
Enable Compression
Compress responses:Cache Static Assets
Set cache headers for assets:Best Practices
- Use environment variables: Never hardcode secrets or configuration
- Enable compression: Compress responses to reduce bandwidth
- Set cache headers: Cache static assets aggressively
- Implement health checks: Monitor application health
- Log strategically: Log errors and important events
- Monitor performance: Track response times and errors
- Use CDNs: Serve static assets from edge locations
- Optimize images: Use appropriate formats and sizes
- Enable security headers: Set CSP, HSTS, and other security headers
- Test deployments: Always test in staging before production