Once you’ve developed and tested your project locally, you’re ready to deploy to production on the Supabase Platform. This guide walks through the deployment process and best practices.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/supabase/supabase/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before deploying, ensure you have:- A Supabase account (sign up here)
- Supabase CLI installed
- Your project initialized locally with migrations
- Tested your migrations with
supabase db reset
Deployment Workflow
Step 1: Create a Project
Create a new project on the Supabase Dashboard:- Click New Project
- Choose your organization
- Enter project details:
- Name: Your project name
- Database Password: Strong password (save this securely)
- Region: Choose closest to your users
- Plan: Select appropriate tier
Your project will take 2-3 minutes to provision.
Step 2: Authenticate with Supabase
Login to the Supabase CLI:Step 3: Link Your Project
Link your local project to the remote project:Step 4: Deploy Migrations
Push your local migrations to production:supabase/migrations/ to your remote database.
Step 5: Verify Deployment
Check your deployed schema in the Dashboard:- Open your project in the Supabase Dashboard
- Navigate to Table Editor
- Verify all tables and columns are present
- Check SQL Editor for any errors
Environment Configuration
Get Production Credentials
Retrieve your production API credentials from the Dashboard:- Go to Project Settings → API
- Copy the following:
- Project URL
- anon public key
- service_role key (keep secret!)
Configure Your Application
Update your application to use production credentials:- Next.js
- React/Vite
- SvelteKit
.env.production
Seeding Production Data (Optional)
For staging environments, you may want to include seed data:Never use seed data in production! Seed files are designed for development and may:
- Overwrite existing data
- Create test accounts
- Insert fake data
Managing Multiple Environments
Strategy 1: Multiple Projects
Create separate Supabase projects for each environment:Strategy 2: Branching (Team/Enterprise)
Use Supabase Branching to create preview environments:Branching is available on Team and Enterprise plans.
Continuous Deployment
GitHub Actions
Automate deployments with GitHub Actions:.github/workflows/deploy.yml
Required Secrets
Add these secrets to your GitHub repository:- SUPABASE_ACCESS_TOKEN: Personal access token from Account Settings
- SUPABASE_DB_PASSWORD: Your database password
- SUPABASE_PROJECT_ID: Your project reference ID
GitHub Actions Setup
Learn more about the official Supabase GitHub Action
Post-Deployment Checklist
After deploying to production, verify the following:Configure Auth Settings
- Enable email confirmations
- Set up custom SMTP for emails
- Configure redirect URLs
- Set appropriate session timeouts
Set Up Network Security
- Enable SSL enforcement
- Configure network restrictions
- Review API settings
Enable Backups
- Daily backups (included in Pro plan)
- Consider Point-in-Time Recovery (PITR) for databases > 4GB
Production Checklist
View the complete production readiness checklist
Schema Changes After Deployment
Making Changes
-
Develop locally:
-
Test thoroughly:
- Run database tests
- Test with seed data
- Verify RLS policies
-
Deploy to production:
Rolling Back Changes
If a migration causes issues:-
Create a rollback migration:
-
Add reversal SQL:
-
Deploy rollback:
Monitoring Deployments
Database Logs
View deployment logs in the Dashboard:- Go to Logs → Database Logs
- Filter by time range
- Look for migration-related entries
API Logs
Monitor API usage:- Go to Logs → API Logs
- Check for errors after deployment
- Verify endpoint response times
Database Performance
Check database performance:- Go to Database → Performance
- Review slow queries
- Check index usage
Troubleshooting
Migration fails on remote
Migration fails on remote
Error:
migration failed to applySolution:- Check remote database logs in Dashboard
- Verify migration works locally:
supabase db reset - Ensure no conflicting schema changes were made in Dashboard
- Check for permission issues
Link command fails
Link command fails
Error:
Failed to link projectSolution:- Verify you’re logged in:
supabase login - Check project ref is correct
- Ensure you have project access
- Try relinking:
supabase link --project-ref <ref>
Push command hangs
Push command hangs
Error: Command appears stuckSolution:
- Check network connection
- Verify database is running (not paused)
- Try with verbose logging:
supabase db push --debug - Check for large migrations (may take time)
Credentials not working
Credentials not working
Error:
Invalid API keySolution:- Regenerate keys in Dashboard: Settings → API
- Check for extra whitespace in environment variables
- Verify you’re using anon key (not service_role) for client
- Ensure keys match your project
Best Practices
1. Always Test Locally First
2. Use Staging Environment
Test in staging before production:3. Document Breaking Changes
Comment migrations that require application updates:4. Deploy During Low-Traffic
Schedule deployments during off-peak hours to minimize impact.5. Monitor After Deployment
Watch for issues in the first hour after deployment:- Check error logs
- Monitor API response times
- Verify key user flows
Next Steps
Production Checklist
Complete pre-launch checklist
Security Best Practices
Secure your production environment
Monitoring & Logs
Set up production monitoring
Branching
Use preview environments for testing
