Supabase Production
Production project setup, migrations, Edge Function deployment, secrets, and monitoring.
Overview
Moving from local Supabase to a production project. This guide covers creating the project, applying migrations, deploying Edge Functions, and configuring secrets.
Production Project Setup
1. Create a Supabase project
- Go to supabase.com/dashboard.
- Click New Project.
- Choose your organization, name, database password, and region.
- Wait for the project to be provisioned.
2. Link your local project
pnpm supabase login
pnpm supabase link --project-ref <your-project-ref>The project ref is in your Supabase dashboard URL: https://supabase.com/dashboard/project/<project-ref>.
3. Get your credentials
From the Supabase dashboard under Settings > API:
- Project URL:
https://xxx.supabase.co - Anon key:
eyJ...(safe for client-side) - Service role key:
eyJ...(server-side only)
Migrations
Apply all migrations to production
pnpm supabase db pushThis runs all migration files from supabase/migrations/ in order against your production database.
Check migration status
pnpm supabase migration listShows which migrations have been applied and which are pending.
Create a new migration
pnpm supabase migration new my_change_nameEdit the generated SQL file, test locally, then push to production.
Pull remote changes
If you made changes directly in the Supabase dashboard (not recommended for production):
pnpm supabase db pullThis generates a migration file capturing the diff.
Edge Functions Deployment
Deploy all functions
pnpm supabase functions deployDeploy a specific function
pnpm supabase functions deploy stripe-checkout
pnpm supabase functions deploy stripe-webhook
pnpm supabase functions deploy stripe-portalVerify deployment
pnpm supabase functions listCheck that all functions show ACTIVE status.
Function URLs
Your Edge Functions are available at:
https://<project-ref>.supabase.co/functions/v1/<function-name>Use this URL for:
- Stripe webhook endpoint configuration
- Client-side
supabase.functions.invoke()calls (handled automatically by the SDK)
Secrets Configuration
Set all required secrets for Edge Functions:
# Stripe
pnpm supabase secrets set STRIPE_SECRET_KEY=sk_live_xxx
pnpm supabase secrets set STRIPE_WEBHOOK_SECRET=whsec_xxx
# Resend
pnpm supabase secrets set RESEND_API_KEY=re_xxx
# URLs
pnpm supabase secrets set SITE_URL=https://yourdomain.com
pnpm supabase secrets set APP_URL=https://app.yourdomain.comVerify secrets are set:
pnpm supabase secrets listNote: SUPABASE_URL, SUPABASE_ANON_KEY, and SUPABASE_SERVICE_ROLE_KEY are automatically available in Edge Functions -- do not set them manually.
Authentication Setup
Configure OAuth providers
- Go to Authentication > Providers in the Supabase dashboard.
- Enable Google, GitHub, or other providers.
- Add the client ID and secret from each provider.
- Set the Redirect URL to:
https://xxx.supabase.co/auth/v1/callback
Configure email templates
- Go to Authentication > Email Templates.
- Customize the confirmation, invitation, and password reset emails.
- Update the redirect URLs to point to your production domain.
Set redirect URLs
Under Authentication > URL Configuration:
- Site URL:
https://app.yourdomain.com - Redirect URLs: Add all allowed redirect URLs:
https://app.yourdomain.com/auth/callback https://app.yourdomain.com/auth/reset-password
Monitoring
Database
- Dashboard > Database: View table sizes, active connections, query performance.
- Dashboard > Logs: SQL query logs, auth logs, Edge Function logs.
Edge Functions
- Dashboard > Edge Functions: View invocation counts, error rates, and logs per function.
- Click on a function to see recent invocations with request/response details.
Alerts
Enable alerts in Settings > Notifications for:
- Database approaching storage limit
- High error rate on Edge Functions
- Auth rate limiting triggered
Production Checklist
- Migrations applied (
pnpm supabase db push) - Edge Functions deployed (
pnpm supabase functions deploy) - All secrets set (
pnpm supabase secrets list) - OAuth providers configured with production credentials
- Email templates customized
- Redirect URLs updated to production domains
- Stripe webhook endpoint set to production Edge Function URL
- RLS policies verified on all tables
- Database backups enabled (requires Supabase Pro plan)
Done reading? Mark this page as complete.