Getting StartedConnect your framework
Next.js + Prisma
Pooled URL for the app, direct URL for migrations, and Prisma handles the rest.
Environment
DATABASE_URL="postgres://user:password@host:6432/db?sslmode=require"
DIRECT_URL="postgres://user:password@host:5432/db?sslmode=require"capydb link writes exactly this when it detects Prisma — DATABASE_URL points at the pooled endpoint and DIRECT_URL at the direct one. If you deploy on Vercel with the Vercel integration, the pushed names are DATABASE_URL (pooled) and DATABASE_URL_UNPOOLED (direct); map directUrl accordingly.
Prisma schema
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}url is what Prisma Client uses at runtime — pooled, safe for serverless. directUrl is what prisma migrate and prisma db push use — direct, because migrations need session-level features the transaction pooler does not provide.
Run it
npx prisma migrate dev # uses DIRECT_URL
npx prisma studio # uses DIRECT_URL
next dev # app traffic over DATABASE_URLPitfalls
- Migrations against the pooled URL fail in confusing ways (advisory lock errors, prepared statement errors). Always set
directUrl. - Serverless connection storms: Prisma Client per-invocation on the direct URL exhausts the plan's connection budget fast. The pooled URL exists for exactly this.
- Preview deployments: a preview database has its own pair of URLs. The Vercel integration scopes them to the git branch automatically; with the GitHub Action they are exported into the workflow env.