Overview
Cajas is optimized for deployment on Vercel, leveraging Next.js 16’s advanced features including React Compiler and server-side rendering. This guide walks through the complete deployment process from initial setup to custom domain configuration.Pre-Deployment Checklist
Before deploying to production, ensure you have:Supabase Project
- Production Supabase project created
- All migrations applied
- RLS policies enabled and tested
- Auth providers configured
Environment Variables
- Production API keys secured
- Database connection strings ready
- Third-party service credentials prepared
Initial Deployment
1. Connect to Vercel
2. Configure Build Settings
Vercel automatically detects Next.js projects. Verify these settings:Build Configuration
Build Configuration
- Framework Preset: Next.js
- Build Command:
next build - Output Directory:
.next - Install Command:
npm install - Node Version: 20.x (recommended)
Advanced Settings
Advanced Settings
next.config.ts
next.config.ts:3-14 enables:- React Compiler for optimized rendering
- Disabled source maps for security
- Webpack warning suppression
Environment Variables
Required Variables
Configure these environment variables in your Vercel project settings:Your Supabase project URLUsed in:
lib/supabase/server.ts:8, lib/supabase/client.ts:5Supabase anonymous (public) key for client-side requestsUsed in:
lib/supabase/server.ts:9, lib/supabase/client.ts:6Service role key for server-side admin operations (keep secret)
Setting Variables on Vercel
- Dashboard
- CLI
- Bulk Import
- Navigate to your project on Vercel
- Go to Settings → Environment Variables
- Add each variable with appropriate scope:
- Production: Live environment
- Preview: Pull request deployments
- Development: Local development
- Click Save
Custom Domains
Adding a Domain
Verify Configuration
Vercel will automatically verify DNS propagation. This typically takes 5-10 minutes but can take up to 48 hours.Check status:
Domain Best Practices
Apex Domain
Use
cajas.club as primary domain for better SEO and brandingWWW Redirect
Configure automatic redirect from
www.cajas.club to apex domainHTTPS Only
Enable “Redirect to HTTPS” in domain settings
HSTS
Enable HTTP Strict Transport Security in headers
Production Optimizations
Performance Configuration
vercel.json
Next.js Configuration
The production build leverages several optimizations:React Compiler
React Compiler
Enabled via
reactCompiler: true in next.config.ts:5Benefits:- Automatic memoization
- Reduced bundle size
- Improved runtime performance
- Better code splitting
Source Maps
Source Maps
Disabled via
productionBrowserSourceMaps: false in next.config.ts:6Security benefits:- Prevents source code exposure
- Reduces bundle size
- Faster page loads
Webpack Optimizations
Webpack Optimizations
Configured in
next.config.ts:7-13Deployment Workflow
Automatic Deployments
Vercel provides automatic deployments for every push:Preview Deployment
Vercel automatically creates a preview deployment with a unique URL:Preview deployments include:
- Full production build
- Preview environment variables
- Unique URL for testing
- Comment on PR with deployment link
Manual Deployments
Troubleshooting
Build Failures
Build Failures
Symptom: Deployment fails during build stepSolutions:
- Check build logs in Vercel dashboard
- Verify environment variables are set
- Test build locally:
- Check for TypeScript errors
- Verify all dependencies are in
package.json
Runtime Errors
Runtime Errors
Symptom: Build succeeds but application crashes at runtimeSolutions:
- Check function logs in Vercel dashboard
- Verify Supabase connection:
- Check CORS configuration
- Verify environment variables are accessible
Database Connection Issues
Database Connection Issues
Symptom: Cannot connect to SupabaseSolutions:
- Verify
NEXT_PUBLIC_SUPABASE_URLis correct - Check Supabase project is active
- Verify API keys are not expired
- Test connection in Supabase dashboard
- Check network/firewall settings
Domain Not Working
Domain Not Working
Symptom: Custom domain shows error or doesn’t loadSolutions:
- Verify DNS propagation:
- Check DNS records match Vercel requirements
- Wait for DNS propagation (up to 48 hours)
- Verify domain is not already in use
- Check domain registrar settings
Post-Deployment
Monitor Performance
Set up logging and monitoring for production traffic
Security Review
Verify security policies and RLS rules are working
Analytics
Configure Vercel Analytics for user insights
Alerts
Set up deployment and error notifications
Next Steps: After deployment, review the Security Best Practices and set up Monitoring to ensure your production environment is secure and observable.
