Documentation Index
Fetch the complete documentation index at: https://mintlify.com/amanvarshney01/create-better-t-stack/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Better-T-Stack projects can be deployed to various platforms. The CLI provides built-in support for Cloudflare Workers deployment via Alchemy, and generated projects are compatible with other platforms.Cloudflare Workers deployment
What is Cloudflare Workers?
Cloudflare Workers is a serverless platform that runs your code on Cloudflare’s global edge network (300+ locations). It uses V8 isolates for near-zero cold starts. Benefits:- Global edge distribution
- Sub-millisecond cold starts
- Native TypeScript support
- Generous free tier
- Integrated with D1, R2, KV, Durable Objects
Enabling Cloudflare deployment
Web app deployment:What you get
When Cloudflare deployment is enabled, Better-T-Stack generates:alchemy.run.ts file defines your entire infrastructure:
- Workers for web and/or server
- D1 databases (if using SQLite)
- Environment variables and secrets
- Deployment configuration
Deployment commands
Deploy to production:Environment setup
Before deploying:Configure Cloudflare
Ensure you have:
- Cloudflare account
- API token with Workers permissions
- Workers subdomain configured
Multi-stage deployments
Deploy to multiple environments (dev, staging, prod): Environment variables method:CI/CD
For GitHub Actions or other CI:ALCHEMY_PASSWORD- Encryption password for secretsCLOUDFLARE_API_TOKEN- Cloudflare API token- Any other environment-specific secrets
Other deployment platforms
Better-T-Stack projects work with standard deployment platforms:Vercel
Supported frameworks:- Next.js
- TanStack Start
- SvelteKit
- Nuxt
- Connect your Git repository to Vercel
- Vercel auto-detects framework
- Add environment variables in dashboard
- Deploy
Netlify
Supported frameworks:- Next.js
- SvelteKit
- Nuxt
- Astro
- Connect repository to Netlify
- Set build command:
bun run build - Set publish directory (framework-specific)
- Add environment variables
- Deploy
Railway
Best for:- Backend APIs (Hono, Express, Fastify, Elysia)
- Full-stack apps with databases
- Create new project from GitHub repo
- Railway auto-detects and deploys
- Add environment variables
- Database services available in dashboard
Render
Supported:- Web services (any framework)
- Background workers
- Databases (PostgreSQL, Redis)
- Create new web service
- Connect repository
- Set build command and start command
- Add environment variables
- Deploy
Self-hosted (VPS, Docker)
Docker: Better-T-Stack projects can be containerized:Database deployment
Managed providers
For production databases, use managed providers: SQLite:- Turso (recommended for SQLite)
- Cloudflare D1 (for Workers)
- Neon (serverless)
- Supabase (with auth/storage)
- Railway (simple deployment)
- Render (free tier)
- PlanetScale (serverless)
- Railway
- Render
- MongoDB Atlas (official)
- Railway
Connection security
Use connection pooling: For serverless deployments, use connection pooling to avoid exhausting database connections:- Use environment variables
- Never commit
.envfiles - Use secrets management (GitHub Secrets, Doppler, etc.)
- For Alchemy, use
alchemy.secret.envfor automatic encryption
Environment variables
Production checklist
Managing secrets
Option 1: Platform-specific- Vercel: Environment Variables in dashboard
- Netlify: Site settings > Environment variables
- Railway: Variables tab
- Cloudflare: Alchemy encrypted secrets
- Doppler - Centralized secrets management
- Infisical - Open source secrets platform
- AWS Secrets Manager
- HashiCorp Vault
Post-deployment
Verify deployment
Monitoring
Add health checks:Troubleshooting
Build fails
Build fails
Common causes:
- Missing dependencies in
package.json - TypeScript errors
- Environment variables not set
- Run
bun run buildlocally to reproduce - Check build logs for specific errors
- Verify all dependencies are listed
Runtime errors
Runtime errors
Common causes:
- Missing environment variables
- Database connection issues
- CORS misconfiguration
- Check platform logs
- Verify all required env vars are set
- Test database connection string locally
- Verify CORS origins match exactly
Slow cold starts
Slow cold starts
Solutions:
- Use Cloudflare Workers (V8 isolates, not containers)
- Reduce bundle size
- Use dynamic imports for large dependencies
- Consider keeping functions warm with scheduled pings
Database connection pool exhausted
Database connection pool exhausted
Solutions:
- Use connection pooling (Neon, Supabase, PlanetScale all provide this)
- Reduce max connections per function
- Use serverless-friendly databases
- Implement connection caching
Next steps
Cloudflare with Alchemy
Complete guide to Cloudflare Workers deployment
Database setup
Configure production databases
Project structure
Understand generated project layout
Troubleshooting
Common issues and solutions