Deployment
Deploy your SaaS to Vercel and configure production
Deployment
Deploy your SaaS to Vercel with these steps.
Prerequisites
Before deploying, ensure you have:
- Supabase project with production database
- Stripe account with live API keys
- Resend account with verified domain
- GitHub repository with your code
Deploy to Vercel
1. Push to GitHub
git add .
git commit -m "Ready for deployment"
git push origin main2. Import to Vercel
- Go to vercel.com
- Click "Add New Project"
- Import your GitHub repository
- Configure environment variables (see below)
- Click "Deploy"
3. Environment Variables
Add these in Vercel → Settings → Environment Variables:
# App
NEXT_PUBLIC_APP_URL=https://yourdomain.com
NEXT_PUBLIC_APP_NAME=Your App Name
# Supabase
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
# Stripe (use live keys!)
STRIPE_SECRET_KEY=sk_live_...
STRIPE_WEBHOOK_SECRET=whsec_...
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_...
STRIPE_PRO_PRICE_ID=price_...
# Resend
RESEND_API_KEY=re_...
RESEND_FROM_EMAIL=hello@yourdomain.comPost-Deployment
Configure Supabase
- Go to Supabase Dashboard → Authentication → URL Configuration
- Update Site URL to your production domain
- Add redirect URLs:
https://yourdomain.com/auth/callbackhttps://yourdomain.com/auth/reset-password
Configure Stripe Webhooks
- Go to Stripe Dashboard → Developers → Webhooks
- Add endpoint:
https://yourdomain.com/api/webhooks/stripe - Select events:
checkout.session.completedcustomer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedinvoice.payment_succeededinvoice.payment_failed
- Copy the webhook secret and add to Vercel
Configure Custom Domain
- In Vercel → Settings → Domains
- Add your custom domain
- Configure DNS as instructed
Pre-Deployment Checklist
# Build locally first
npm run build
# Run tests
npm run test
# Check for lint errors
npm run lintSecurity Checklist
- Using HTTPS (automatic with Vercel)
- Environment variables are set (not hardcoded)
- RLS is enabled on all Supabase tables
- Stripe webhook secret is configured
- No secrets in client-side code
SEO Checklist
-
src/config/site.tshas correct metadata - Open Graph images are configured
- Sitemap is generated (
/sitemap.xml) - robots.txt allows crawling
Monitoring
Vercel Analytics
Enable in Vercel → Analytics for:
- Page views
- Web Vitals
- Geographic data
Error Tracking
Consider adding error tracking:
Troubleshooting
Build Fails
# Check build locally
npm run build
# Check for TypeScript errors
npx tsc --noEmitWebhooks Not Working
- Check webhook secret matches
- Verify endpoint is correct
- Check Stripe webhook logs
- Ensure API route is deployed
Auth Redirects Fail
- Verify redirect URLs in Supabase
- Check
NEXT_PUBLIC_APP_URLis correct - Ensure callback route exists
Continuous Deployment
Vercel automatically deploys on push to main. For preview deployments:
- Push to a branch → Preview URL generated
- Open PR → Preview deployment with comments
- Merge to main → Production deployment