Quick deploy
Configure environment variables
During deployment, you’ll be prompted to set:Required:
OPENAI_API_KEY- Your OpenAI API key from platform.openai.com
DATABASE_URL- PostgreSQL connection stringKEY_VAULTS_SECRET- Encryption key for sensitive dataAUTH_SECRET- Secret for authentication (auto-generated if not set)
Prerequisites
Required external services
PostgreSQL database (required)
PostgreSQL database (required)
Choose a managed PostgreSQL provider:Recommended options:
- Neon - Serverless Postgres with free tier
- Supabase - Postgres + storage + auth
- Vercel Postgres - Native Vercel integration
- Railway - Simple Postgres hosting
- Render - Free tier available
DATABASE_URL in the format:Redis (optional but recommended)
Redis (optional but recommended)
For better performance with session storage and caching:Recommended options:
- Upstash Redis - Serverless Redis with free tier
- Vercel KV - Native Vercel integration
- Redis Cloud - Managed Redis
REDIS_URL:S3-compatible storage (for file uploads)
S3-compatible storage (for file uploads)
Required if you want file upload and knowledge base features:Recommended options:See Storage Configuration for details.
- Cloudflare R2 - S3-compatible, no egress fees
- AWS S3 - Industry standard
- Backblaze B2 - Cost-effective
- Vercel Blob - Native integration
Environment variables
Configure in Vercel dashboard
- Go to your project in Vercel Dashboard
- Navigate to Settings → Environment Variables
- Add the required variables:
Essential variables
Generate secure secrets
Custom domain
Add domain in Vercel
- Go to Settings → Domains
- Click Add Domain
- Enter your domain (e.g.,
lobehub.example.com)
Configure DNS
Add the DNS records provided by Vercel:For subdomain (e.g., For apex domain (e.g.,
lobehub.example.com):example.com):Limitations
Serverless function timeout
- Hobby plan: 10 seconds
- Pro plan: 60 seconds
- Enterprise: 900 seconds
No WebSocket support
Vercel serverless functions don’t support persistent WebSocket connections. Impact: Real-time features use Server-Sent Events (SSE) instead.Cold starts
Serverless functions may experience cold starts after periods of inactivity. Impact: First request after idle period may be slower (1-3 seconds).File size limits
- Deployment size: 250 MB (compressed)
- Function size: 50 MB
Deployment workflow
Automatic deployments
By default, Vercel automatically deploys:- Production: Every push to
mainbranch - Preview: Every push to other branches and PRs
Manual deployments
- Go to Vercel Dashboard
- Select your project
- Click Deployments
- Click Redeploy on any previous deployment
Deploy via CLI
Keeping updated
Enable auto-sync from upstream
To enable updates:Fork the repository
Manually fork lobehub/lobe-chat on GitHub.
Import to Vercel
- Go to Vercel Dashboard
- Click Add New → Project
- Import your forked repository
- Configure environment variables
- Deploy
Enable GitHub Actions
In your fork, go to Actions tab and enable:
upstream-syncworkflow (syncs from original repo)
Database migrations
LobeHub automatically runs database migrations on deployment.
- Check deployment logs in Vercel dashboard
- Verify
DATABASE_URLis correct - Ensure database is accessible (check IP allowlist)
- Run migrations manually:
Troubleshooting
Deployment fails
Deployment fails
Check build logs in Vercel dashboard:
- Go to Deployments
- Click on failed deployment
- Check Build Logs
- Missing environment variables
- TypeScript errors
- Out of memory (increase Node memory:
NODE_OPTIONS=--max-old-space-size=4096)
Function timeout
Function timeout
If requests timeout on Hobby plan:
- Upgrade to Pro plan for 60s timeout
- Use faster AI models (e.g., GPT-3.5 instead of GPT-4)
- Reduce max tokens in responses
- Enable streaming (default)
Database connection fails
Database connection fails
Verify connection:
- Check
DATABASE_URLformat - Ensure
?sslmode=requireis appended for managed databases - Check database IP allowlist (allow Vercel IPs or use
0.0.0.0/0) - Test connection locally:
502 Bad Gateway
502 Bad Gateway
Common causes:
- Function timeout (see above)
- Out of memory
- Database connection pool exhausted
- Use connection pooler (PgBouncer)
- Reduce concurrent connections
- Check database logs
Environment variables not updating
Environment variables not updating
After changing environment variables:
- Go to Deployments
- Click Redeploy (three dots menu)
- Select Use existing Build Cache: No
Cost optimization
Vercel pricing
- Hobby: Free, 100 GB-hours/month
- Pro: $20/month, unlimited bandwidth
- Enterprise: Custom pricing
Reduce costs
- Use external caching - Upstash Redis reduces function invocations
- Optimize images - Use Vercel Image Optimization
- CDN caching - Configure
Cache-Controlheaders - Function regions - Deploy to regions close to users
Database costs
- Neon: Free tier with 0.5 GB storage
- Supabase: Free tier with 500 MB database
- Vercel Postgres: Starts at $10/month
Next steps
Environment variables
Complete environment variable reference
Authentication
Set up SSO and user management
Database
Configure PostgreSQL and run migrations
Storage
Set up S3 for file uploads