You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Persistent connections → Connect to database per request
File system storage → Use external storage (AWS S3, etc.)
What Stays the Same
MongoDB Atlas database
Auth0 authentication
Frontend React application
API contract and responses
Migration Steps
# 1. Create API functions from Express routes
mkdir api/sessions api/ai
cp backend/src/routes/*.ts api/
# Edit each file for Vercel serverless format# 2. Create vercel.json configuration# 3. Set environment variables in Vercel# 4. Deploy
vercel --prod
From Traditional Hosting
Key Differences
No server provisioning - Vercel handles everything
Pay-per-execution instead of fixed server costs
Automatic scaling instead of manual load balancing
Built-in CDN instead of separate CDN setup
💰 Cost Comparison
Vercel Pricing (as of 2025)
Hobby Plan: $0/month (personal projects)
100GB bandwidth
3,000 function invocations
100GB function seconds
Pro Plan: $20/month (commercial)
1TB bandwidth
30,000 function invocations
1,000GB function seconds
Enterprise: Custom pricing
Docker Deployment Costs
Server: $5-50/month (depending on specs)
Domain/SSL: $10-20/year
CDN: $10-100/month (optional)
Maintenance: Developer time
Break-even Analysis
Light usage (<10k requests/month): Vercel cheaper
Medium usage (10k-100k requests): Similar costs
Heavy usage (>100k requests): Docker potentially cheaper
⚡ Performance Comparison
Response Times
Vercel: 100-500ms (including cold starts)
Docker (optimized): 50-200ms
Traditional server: 20-100ms
Scaling
Vercel: Automatic, global CDN
Docker: Manual scaling required
Traditional: Load balancer configuration
Availability
Vercel: 99.9%+ SLA
Docker: Depends on hosting provider
Traditional: Depends on infrastructure
🔧 Technical Differences
Database Connections
// Vercel: Connect per request (serverless)exportdefaultasyncfunctionhandler(req,res){awaitconnectDatabase();// Connect each time// ... handle request}// Docker: Persistent connectionconstapp=express();connectDatabase();// Connect once on startupapp.listen(port);
CORS Handling
// Vercel: Set headers in each functionres.setHeader('Access-Control-Allow-Origin',process.env.FRONTEND_URL);res.setHeader('Access-Control-Allow-Credentials','true');// Express: Use middlewareapp.use(cors({origin: process.env.FRONTEND_URL,credentials: true}));
Environment Variables
# Vercel: Set in dashboard or CLI
vercel env add VARIABLE_NAME
# Docker: Use .env fileecho"VARIABLE_NAME=value">> .env