Deployment
Step-by-step guide to deploying your SaaS with Vercel, setting up production services like Supabase, Stripe, and Sanity, and ensuring performance, security, and monitoring.
Deployment
Deploy your SaaS to production with Vercel and configure all services for live usage.
Vercel Deployment
One-Click Deploy
- Push code to GitHub repository
- Connect repository to Vercel
- Deploy automatically on push
Environment Variables
Add all variables from .env.local
to Vercel:
# Production URLs
NEXT_PUBLIC_SITE_URL=https://yourdomain.com
# Database (keep same Supabase project or create production instance)
NEXT_PUBLIC_SUPABASE_URL=your_production_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_production_key
SUPABASE_SERVICE_ROLE_KEY=your_production_service_key
# Payments (switch to live keys)
STRIPE_SECRET_KEY=sk_live_your_live_secret_key
STRIPE_PUBLISHABLE_KEY=pk_live_your_live_publishable_key
STRIPE_WEBHOOK_SECRET=whsec_your_production_webhook_secret
# Email & Analytics (same keys work for production)
RESEND_API_KEY=your_resend_key
NEXT_PUBLIC_POSTHOG_KEY=your_posthog_key
NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
# CMS (same project or create production dataset)
NEXT_PUBLIC_SANITY_PROJECT_ID=your_sanity_project_id
NEXT_PUBLIC_SANITY_DATASET=production
Production Configuration
Supabase Production
- Option 1: Use same project with RLS (recommended for MVP)
- Option 2: Create separate production project
- Update auth redirect URLs to your domain
- Configure email templates with production URLs
Stripe Live Mode
- Switch to live API keys in Vercel
- Update webhook endpoint:
https://yourdomain.com/api/webhooks/stripe
- Test with real payment method
- Monitor transactions in Stripe dashboard
Domain Setup
- Add custom domain in Vercel
- Configure DNS records
- SSL certificate auto-generated
- Update all service URLs to use custom domain
Analytics Setup
PostHog automatically tracks production traffic with existing configuration.
Performance Optimization
Caching Strategy
- Static pages cached at edge
- API routes cached appropriately
- Images optimized via Next.js Image component
Database Optimization
- Connection pooling enabled by default
- RLS policies optimize query performance
- Indexes added for common queries
Security Checklist
- ✅ Environment variables in Vercel (not in code)
- ✅ API routes protected with authentication
- ✅ Database RLS policies enabled
- ✅ HTTPS enforced for all traffic
- ✅ Webhook signature verification
- ✅ CORS configured properly
Monitoring
Built-in Monitoring
- Vercel Analytics - Page views and performance
- PostHog - User behavior and funnels
- Stripe Dashboard - Payment monitoring
- Supabase Dashboard - Database metrics
Error Tracking
Add Sentry for production error tracking:
npm install @sentry/nextjs
npx @sentry/wizard -i nextjs
Post-Deployment
Testing Checklist
- Homepage loads correctly
- User registration works
- Email verification sent
- Login/logout functions
- Payment flow completes
- Webhooks process correctly
- Protected routes redirect properly
- Blog posts load from Sanity
Go-Live Tasks
- DNS propagation - Wait for domain to resolve globally
- Search console - Add site to Google Search Console
- Sitemap - Verify sitemap.xml generates correctly
- Social sharing - Test og:image and meta tags
- Email deliverability - Test all transactional emails
Scaling Considerations
Database Scaling
- Supabase auto-scales with usage
- Consider read replicas for high traffic
- Monitor connection limits
Edge Functions
- Move heavy API operations to Supabase Edge Functions
- Reduce cold start times for critical paths
CDN Optimization
- Images served via Vercel's Edge Network
- Static assets cached globally
- API responses cached at edge when appropriate
Troubleshooting
Build failures: Check environment variables and dependencies 404 errors: Verify routing and middleware configuration Auth issues: Check redirect URLs in Supabase settings Payment failures: Confirm webhook endpoint and live keys Email not sending: Verify domain authentication in Resend
Your SaaS is now live and ready for users!
Database
Comprehensive guide to the pre-configured database setup using Supabase and Sanity CMS, including tables, content handling, user management, and integration examples.
Getting Started
Introduction to the Next.js 15 SaaS Starter Template, including setup steps, tech stack, project structure, and how to launch your SaaS quickly.