Next.js + Prisma
Connect Next.js and Prisma to a CapyDB Postgres database: pooled DATABASE_URL for the app, DIRECT_URL for migrations, and Prisma 7 setup with capydb init prisma.
Environment
DATABASE_URL="postgres://user:password@host:6432/db?sslmode=verify-full"
DIRECT_URL="postgres://user:password@host:5432/db?sslmode=verify-full"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
This page shows the Prisma 6 datasource. For Prisma ORM 7, where the connection URL moved out
of the schema into prisma.config.ts and the client takes a driver adapter, run
capydb init prisma in the linked project: it writes prisma.config.ts (migrations on the direct
URL), prisma/schema.prisma, and a client on @prisma/adapter-pg over the pooled URL - see the
CLI reference.
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.
Connect your framework
Connect any framework to CapyDB Postgres: Prisma, Drizzle, Node.js, Django, Rails, Laravel, Go and SQLAlchemy. Pooled URL for the app, direct URL for migrations.
Drizzle
First-class Drizzle ORM setup with @capydb/drizzle - scaffolded config, pooler-safe defaults, and a schema generated from the live database.