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.local file - it contains secrets!

Manual Reference

If you prefer to set variables manually, here's what you need:

Supabase (Required)

VariableWhere to FindRequired
NEXT_PUBLIC_SUPABASE_URLSupabase → Settings → API → Project URLYes
NEXT_PUBLIC_SUPABASE_ANON_KEYSupabase → Settings → API → anon public keyYes
SUPABASE_SERVICE_ROLE_KEYSupabase → Settings → API → service_role keyYes

Site Configuration (Required)

VariableValueRequired
NEXT_PUBLIC_SITE_URLYour production URL (e.g., https://app.yourdomain.com)Yes
NEXT_PUBLIC_PRODUCT_NAMEYour product nameOptional

Database Webhooks

VariableValueRequired
SUPABASE_DB_WEBHOOK_SECRETGenerate secure random string (32+ chars)Yes

Email Configuration

VariableValueRequired
MAILER_PROVIDERresend (recommended)If using email
RESEND_API_KEYYour Resend API keyIf using Resend
EMAIL_SENDERApp Name <noreply@yourdomain.com>If using email
CONTACT_EMAILEmail for contact form submissionsIf using contact form

Stripe (Billing)

VariableValueRequired
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEYStripe publishable keyIf using billing
STRIPE_SECRET_KEYStripe secret keyIf using billing
STRIPE_WEBHOOK_SECRETStripe webhook signing secretIf using billing

Monitoring (Optional)

VariableValueRequired
NEXT_PUBLIC_MONITORING_PROVIDERsentry or otherOptional
NEXT_PUBLIC_SENTRY_DSNSentry DSNIf 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_URL to 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_SECRET in Vercel

Troubleshooting

Build Fails

  1. Check Vercel build logs for specific error
  2. Ensure all required env vars are set
  3. Run pnpm build locally to reproduce

Auth Not Working

  1. Verify Supabase URL Configuration matches your domain
  2. Check redirect URLs include your domain with /** wildcard
  3. Ensure NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY are correct

Database Connection Issues

  1. Verify SUPABASE_SERVICE_ROLE_KEY is correct
  2. 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:

  1. Push changes to main branch
  2. Vercel auto-deploys on push
  3. If database changes exist, run migrations:
cd apps/web
npx supabase db push