Deployment
Deploy your SaaS application to any hosting platform.
This guide covers the general steps to deploy your application to any hosting platform that can run a Node.js server. TanStack Start builds a server bundle (via Vite + Nitro) that you run with Node.
Deployment Overview
Deploying your application involves these key steps:
- Provision infrastructure - Database, storage, and hosting
- Configure environment variables - Set production credentials
- Deploy the application - Push code to your hosting platform
- Run database migrations - Set up your database schema
- Configure webhooks - Connect your billing provider
Infrastructure Requirements
Your production environment needs:
| Component | Purpose | Options |
|---|---|---|
| Hosting | Run your TanStack Start app | Railway, AWS, Fly.io, any Node host |
| Database | PostgreSQL database | Neon, PlanetScale, Supabase, Railway |
| Storage | File uploads | AWS S3, Cloudflare R2, Railway Storage |
| Transactional emails | Resend, Postmark, SendGrid |
Environment Variables
Every hosting platform requires you to set environment variables. Copy these from your Environment Setup:
Core Variables
DATABASE_URL=postgresql://...VITE_SITE_URL=https://your-domain.comVITE_BILLING_PROVIDER=stripePublic values are inlined at build time
VITE_* variables are inlined into the bundle during pnpm build. Make sure they are present in the build environment, not only at runtime.
Storage Variables
STORAGE_BASE_URL=https://...STORAGE_S3_ACCESS_KEY_ID=...STORAGE_S3_SECRET_ACCESS_KEY=...STORAGE_S3_BUCKET=...STORAGE_S3_REGION=...Billing Variables
For Stripe:
STRIPE_SECRET_KEY=sk_live_...STRIPE_WEBHOOK_SECRET=whsec_...For Polar:
POLAR_ACCESS_TOKEN=...Additional Environment Variables
If you configured additional settings during development (OAuth providers, email, feature flags, etc.), make sure to add those environment variables to your production environment as well. Refer to the Environment Setup guide for the complete list.
Build Configuration
For the monorepo structure, configure your hosting platform:
- Root Directory:
apps/web - Install Command:
pnpm install - Build Command:
pnpm build(orpnpm --filter web build) - Output Directory:
apps/web/.output(Nitro server build) - Start Command:
node apps/web/.output/server/index.mjs(fromapps/web:pnpm start)
Database Migrations
After your first deployment, run Prisma migrations to create the database schema:
read -s DATABASE_URL && export DATABASE_URL && pnpm --filter "@kit/database" prisma:migrateThis command:
- Prompts for your
DATABASE_URL(hidden input) - Exports it as an environment variable
- Runs the Prisma migration
Post-Deployment Checklist
After deploying:
- [ ] Application loads without errors
- [ ] Database connection works
- [ ] Authentication flows work (sign up, sign in)
- [ ] Billing webhooks receive events
- [ ] File uploads work
- [ ] Emails send successfully
Platform Guides
For step-by-step instructions on specific platforms:
- Railway - All-in-one platform with built-in database and storage