Deployment
Production deployment checklist for deploying to Vercel with Supabase.
This guide covers deploying the apps/web Next.js application to Vercel with Supabase.
Prerequisites
- Vercel account with project created
- Supabase project created (production instance)
- Access to Supabase Dashboard
- Access to Vercel Dashboard
1. Vercel Project Configuration
Root Directory
In Vercel Dashboard → Settings → General:
- Set Root Directory to
apps/web
Build Settings
These should auto-detect, but verify:
- Framework Preset: Next.js
- Build Command:
pnpm build(or leave default) - Install Command:
pnpm install
2. Environment Variables
Generate Environment Variables (Recommended)
Run the interactive wizard to generate all required environment variables:
pnpm env:generate
This walks you through each variable and outputs a file at: turbo/generators/templates/env/.env.local
Copy those values into Vercel Dashboard → Settings → Environment Variables.
Note: Never commit the generated
.env.localfile - it contains secrets!
Manual Reference
If you prefer to set variables manually, here's what you need:
Supabase (Required)
| Variable | Where to Find | Required |
|---|---|---|
NEXT_PUBLIC_SUPABASE_URL | Supabase → Settings → API → Project URL | Yes |
NEXT_PUBLIC_SUPABASE_ANON_KEY | Supabase → Settings → API → anon public key | Yes |
SUPABASE_SERVICE_ROLE_KEY | Supabase → Settings → API → service_role key | Yes |
Site Configuration (Required)
| Variable | Value | Required |
|---|---|---|
NEXT_PUBLIC_SITE_URL | Your production URL (e.g., https://app.yourdomain.com) | Yes |
NEXT_PUBLIC_PRODUCT_NAME | Your product name | Optional |
Database Webhooks
| Variable | Value | Required |
|---|---|---|
SUPABASE_DB_WEBHOOK_SECRET | Generate secure random string (32+ chars) | Yes |
Email Configuration
| Variable | Value | Required |
|---|---|---|
MAILER_PROVIDER | resend (recommended) | If using email |
RESEND_API_KEY | Your Resend API key | If using Resend |
EMAIL_SENDER | App Name <noreply@yourdomain.com> | If using email |
CONTACT_EMAIL | Email for contact form submissions | If using contact form |
Stripe (Billing)
| Variable | Value | Required |
|---|---|---|
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY | Stripe publishable key | If using billing |
STRIPE_SECRET_KEY | Stripe secret key | If using billing |
STRIPE_WEBHOOK_SECRET | Stripe webhook signing secret | If using billing |
Monitoring (Optional)
| Variable | Value | Required |
|---|---|---|
NEXT_PUBLIC_MONITORING_PROVIDER | sentry or other | Optional |
NEXT_PUBLIC_SENTRY_DSN | Sentry DSN | If using Sentry |
3. Supabase Configuration
Authentication URLs
In Supabase Dashboard → Authentication → URL Configuration:
- Site URL: Set to your production URL (e.g.,
https://app.yourdomain.com) - Redirect URLs: Add
https://app.yourdomain.com/**
Email Templates (Optional)
In Supabase Dashboard → Authentication → Email Templates:
- Customize confirmation email template
- Customize password reset email template
- Update "From" email address
Database Webhooks (If Using)
In Supabase Dashboard → Database → Webhooks:
- Configure webhook URL:
https://app.yourdomain.com/api/db/webhook - Set webhook secret to match
SUPABASE_DB_WEBHOOK_SECRET
4. Database Migration
Push local migrations to production Supabase:
# From repository root cd apps/web # Link to your production Supabase project npx supabase link --project-ref YOUR_PROJECT_REF # Push migrations to production npx supabase db push
Find your Project Ref: Supabase Dashboard → Settings → General → Reference ID
Verify Migration
- Check Supabase Dashboard → Table Editor to confirm tables exist
- Check Supabase Dashboard → Database → Migrations to see applied migrations
5. Deploy
Initial Deploy
# Push to your connected branch (usually main) git push origin main
Or trigger manually in Vercel Dashboard → Deployments → Redeploy.
Verify Deployment
- Check Vercel build logs for errors
- Visit production URL
- Test authentication flow (sign up, sign in)
- Test protected routes
6. Post-Deployment
Custom Domain (Optional)
In Vercel Dashboard → Settings → Domains:
- Add custom domain
- Configure DNS records as instructed
- Update
NEXT_PUBLIC_SITE_URLto custom domain - Update Supabase Site URL and Redirect URLs
Stripe Webhooks (If Using Billing)
In Stripe Dashboard → Developers → Webhooks:
- Add endpoint:
https://app.yourdomain.com/api/billing/webhook - Select events to listen for
- Copy signing secret to
STRIPE_WEBHOOK_SECRETin Vercel
Troubleshooting
Build Fails
- Check Vercel build logs for specific error
- Ensure all required env vars are set
- Run
pnpm buildlocally to reproduce
Auth Not Working
- Verify Supabase URL Configuration matches your domain
- Check redirect URLs include your domain with
/**wildcard - Ensure
NEXT_PUBLIC_SUPABASE_URLandNEXT_PUBLIC_SUPABASE_ANON_KEYare correct
Database Connection Issues
- Verify
SUPABASE_SERVICE_ROLE_KEYis correct - Check Supabase project is not paused (free tier pauses after inactivity)
Quick Reference: Environment Variables
Copy this template and fill in values:
# Supabase (Required) NEXT_PUBLIC_SUPABASE_URL=https://xxxxx.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ... SUPABASE_SERVICE_ROLE_KEY=eyJ... # Site (Required) NEXT_PUBLIC_SITE_URL=https://app.yourdomain.com # Webhooks SUPABASE_DB_WEBHOOK_SECRET=your-secure-random-string # Email (Optional) MAILER_PROVIDER=resend RESEND_API_KEY=re_xxxxx EMAIL_SENDER=App Name <noreply@yourdomain.com> CONTACT_EMAIL=support@yourdomain.com # Stripe (Optional) NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_xxxxx STRIPE_SECRET_KEY=sk_live_xxxxx STRIPE_WEBHOOK_SECRET=whsec_xxxxx
Updating Production
For subsequent deployments:
- Push changes to main branch
- Vercel auto-deploys on push
- If database changes exist, run migrations:
cd apps/web npx supabase db push