IMPORTANT: For Vercel serverless functions, you MUST use the Transaction Pooler (port 6543) to avoid connection limit errors.
Use the PRISMA/Transaction Pooler URL (port 6543 with pgbouncer=true):
postgres://postgres.rxbitapqomwllggjyrvk:KS3xayqmT8OKISxD@aws-1-us-east-1.pooler.supabase.com:6543/postgres?sslmode=require&pgbouncer=true
Why? Vercel serverless functions create many concurrent instances. The transaction pooler handles this much better than direct connections.
-
Go to your Vercel project dashboard
-
Add the Database URL Environment Variable:
- Key:
DATABASE_URL(orstridelens_POSTGRES_PRISMA_URL) - Value:
postgres://postgres.rxbitapqomwllggjyrvk:KS3xayqmT8OKISxD@aws-1-us-east-1.pooler.supabase.com:6543/postgres?sslmode=require&pgbouncer=true - Environments: Select all (Production, Preview, Development)
- Click Save
- Key:
-
Alternatively, use the prefixed variable:
- Key:
stridelens_POSTGRES_PRISMA_URL - Value:
postgres://postgres.rxbitapqomwllggjyrvk:KS3xayqmT8OKISxD@aws-1-us-east-1.pooler.supabase.com:6543/postgres?sslmode=require&pgbouncer=true
- Key:
-
Redeploy your application - migrations will run automatically!
Once the DATABASE_URL is set:
- ✅ Django will automatically connect to Supabase PostgreSQL
- ✅ Migrations will run automatically on first request
- ✅ All data will persist across deployments and devices
- ✅ Users can log in from any device and see their saved routes
To test with Supabase locally, create a .env file in your project root:
For local development, you can use the non-pooling URL (port 5432):
DATABASE_URL=postgres://postgres.rxbitapqomwllggjyrvk:KS3xayqmT8OKISxD@aws-1-us-east-1.pooler.supabase.com:5432/postgres?sslmode=requireFor production/Vercel, use the transaction pooler (port 6543):
DATABASE_URL=postgres://postgres.rxbitapqomwllggjyrvk:KS3xayqmT8OKISxD@aws-1-us-east-1.pooler.supabase.com:6543/postgres?sslmode=require&pgbouncer=trueThen run migrations:
python manage.py migrateThese credentials are sensitive. Make sure:
- ✅ Never commit
.envfiles to git - ✅ Use environment variables in Vercel (not hardcoded)
- ✅ Rotate credentials if they're exposed