Skip to main content

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:
This creates optimized bundles for both client and server in the dist directory.

Cloudflare Workers

Deploy to Cloudflare’s edge network for global, low-latency serving.
1

Configure Wrangler

Create a wrangler.jsonc file:
2

Add Wrangler Scripts

Update your package.json:
3

Deploy

Deploy to Cloudflare:

Environment Variables

Set environment variables in Wrangler:
For secrets (not committed to source control):

Cloudflare Bindings

Access Cloudflare services (KV, D1, R2) in your app:
Configure bindings in wrangler.jsonc:

Vercel

Deploy to Vercel’s edge and serverless infrastructure.
1

Install Vercel CLI

2

Configure Project

Create vercel.json (optional):
3

Deploy

Deploy to Vercel:
For production:

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.
1

Install Netlify CLI

2

Configure Project

Create netlify.toml:
3

Deploy

Deploy to Netlify:
For production:

Environment Variables

Set environment variables in Netlify Dashboard or CLI:

Node.js Server

Deploy to any Node.js hosting provider (AWS, DigitalOcean, Railway, etc.).
1

Create Server Entry

Create a production server file:
2

Build and Start

Docker Deployment

Create a Dockerfile:
Build and run:

Static Export

Generate a static site for deployment to static hosts (GitHub Pages, S3, etc.).
1

Configure Static Routes

Define routes to prerender:
2

Build Static Site

Generated files are in dist/client.
3

Deploy Static Files

Deploy dist/client to any static host:

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:
Use in server functions:

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

Learn More