Skip to main content

Deployment

TanStack Start can be deployed to various hosting platforms. This guide covers deployment strategies and platform-specific configurations.

Build Process

Before deploying, build your application:
This creates optimized production bundles in the .output directory.

Deployment Targets

TanStack Start uses Nitro as its server engine, supporting multiple deployment targets.

Node.js Server

Deploy as a standalone Node.js application:

Configuration

Build and Run

Environment Variables

Docker Deployment

Build and run:

Cloudflare Workers

Deploy to Cloudflare’s edge network:

Configuration

Deploy

wrangler.toml

Using Cloudflare Bindings

Vercel

Deploy to Vercel’s platform:

Configuration

Deploy

Environment Variables

Add environment variables in the Vercel dashboard:
  • Settings → Environment Variables
  • Add variables for each environment (Production, Preview, Development)

Netlify

Deploy to Netlify:

netlify.toml

Deploy

AWS

AWS Lambda

Deploy as Lambda functions:

AWS EC2

Deploy to EC2 instances:
  1. Build the application
  2. Upload to EC2
  3. Install dependencies
  4. Run with PM2:

Static Hosting

For static-only deployments (no server functions):

Configuration

Build

Deploy the .output/public directory to:
  • Cloudflare Pages
  • GitHub Pages
  • Amazon S3
  • Any static host

Reverse Proxy

Run behind a reverse proxy (nginx):

Environment Management

Environment Variables

Create environment-specific files:

Loading Environment Variables

Performance Optimization

Caching

Implement caching strategies:

Compression

Enable compression:

Asset Optimization

Health Checks

Implement health check endpoints:

Monitoring

Error Tracking

Integrate error tracking:

Logging

Implement structured logging:

CI/CD

GitHub Actions

Best Practices

  1. Environment Variables
    • Never commit secrets
    • Use different values per environment
    • Prefix client variables with VITE_
  2. Build Optimization
    • Enable compression
    • Split vendor bundles
    • Optimize images and assets
  3. Monitoring
    • Set up error tracking
    • Implement health checks
    • Monitor performance metrics
  4. Security
    • Use HTTPS in production
    • Set security headers
    • Implement rate limiting
    • Keep dependencies updated
  5. Scaling
    • Use CDN for static assets
    • Implement caching strategies
    • Consider serverless for auto-scaling
  6. Backup & Recovery
    • Automate database backups
    • Document recovery procedures
    • Test disaster recovery

Troubleshooting

Build Errors

Runtime Errors

Check logs:

Performance Issues

  • Enable compression
  • Check database query performance
  • Review bundle sizes
  • Implement caching

Next Steps