Vercel Setup
Project Configuration
Team: Charle AgencyProject: charle-os
Framework: Next.js 16
Build Command:
npm run buildOutput Directory:
.next
Git Integration
Vercel is connected to the GitHub repository: Repository:charle/charle-osProduction Branch:
mainDeploy Previews: All branches Automatic deployments:
- ✅ Push to
main→ Production deployment - ✅ Open PR → Preview deployment
- ✅ Update PR → Preview update
- ✅ Merge PR → Production deployment
Environment Variables
Setting Environment Variables
- Vercel Dashboard
- Vercel CLI
- Go to Vercel Dashboard
- Settings → Environment Variables
- Add variable:
- Name:
DATABASE_URL - Value:
postgresql://... - Environments: Production, Preview, Development
- Name:
- Click “Save”
Environment Scopes
Variables can be scoped to specific environments:| Scope | When Used |
|---|---|
| Production | main branch deployments |
| Preview | PR/branch preview deployments |
| Development | Local development (via vercel dev) |
Required Variables
Core
Integrations
Deployment Configuration
Build Settings
Regions
CharleOS is deployed to:- Primary: London (lhr1) - Closest to users
- Edge: Global CDN for static assets
Build Output
After successful build:.next/- Built applicationpublic/- Static assetsdrizzle/- Migrations (applied during build)
Deployment Workflow
Production Deployment
Preview Deployment
- Unique URL per branch
- Shareable for testing
- Auto-deleted after PR merge
- Comments added to PR with preview URL
Vercel Features
Analytics
Built-in analytics show:- Web Vitals: LCP, FID, CLS, TTFB
- Top Pages: Most visited pages
- Top Referrers: Traffic sources
- Real User Monitoring: Actual user experience
Logs
Real-time logs for debugging: Build Logs:- Dependency installation
- Database migration output
- Build errors/warnings
- API route requests
- Server component logs
- Error stack traces
- Edge function execution
- Regional performance
Speed Insights
Track performance metrics:- Real User Monitoring (RUM)
- Core Web Vitals breakdown
- Page-by-page performance
- Regional performance data
Monitoring
Uptime and performance monitoring:- 99.99% uptime SLA
- Automated health checks
- Incident notifications
- Status page
Custom Domains
CharleOS uses custom domains:Main App
Domain:charle.agencyDNS: Managed by Cloudflare
SSL: Automatic (Vercel) DNS Configuration:
Client Portal
Domain:clients.charle.agencySubdomain: Separate Next.js app deployment DNS Configuration:
Performance Optimization
Caching
Vercel automatically caches: Static Assets:Image Optimization
Next.js Image component uses Vercel’s optimizer:- Automatic WebP/AVIF conversion
- Responsive sizing
- Lazy loading
- CDN caching
Edge Functions
API routes run on Vercel Edge (close to users):Security
HTTPS/SSL
- Automatic SSL certificate provisioning
- TLS 1.3 encryption
- HTTP → HTTPS redirect
- HSTS enabled
DDoS Protection
Vercel provides:- Edge network DDoS mitigation
- Automatic rate limiting
- IP blocking for abuse
Security Headers
Vercel CLI
Installation
Common Commands
Troubleshooting
Build Failures
Error: “Command ‘npm run build’ exited with 1” Fix:- Check build logs in Vercel dashboard
- Run
npm run buildlocally - Fix TypeScript errors
- Check environment variables are set
- Verify migrations don’t have errors
Deployment Timeout
Error: “Build exceeded maximum duration” Fix:- Optimize build (remove unnecessary dependencies)
- Enable build cache
- Contact Vercel support for timeout increase
Environment Variable Not Found
Error: “Missing environment variable: X” Fix:- Go to Vercel Dashboard → Settings → Environment Variables
- Add missing variable
- Select correct environments (Production/Preview)
- Redeploy
Domain Not Resolving
Error: “ERR_NAME_NOT_RESOLVED” Fix:- Check DNS configuration in Cloudflare
- Verify CNAME points to
cname.vercel-dns.com - Wait for DNS propagation (up to 48 hours)
- Use
dig charle.agencyto check DNS
Best Practices
Use Preview Deployments
Use Preview Deployments
Always test in preview before merging:
- Open PR
- Wait for preview deployment
- Test preview URL thoroughly
- Merge to main when confirmed working
Separate Production and Preview Variables
Separate Production and Preview Variables
Use different credentials for preview:
- Production: Real database, real API keys
- Preview: DEV database, test API keys
- Never mix environments
Monitor After Deployment
Monitor After Deployment
Check Vercel Analytics after deploying:
- Verify traffic is flowing
- Check for errors in logs
- Monitor Core Web Vitals
Keep Build Fast
Keep Build Fast
Optimize build time:
- Remove unused dependencies
- Enable build caching
- Minimize dynamic imports