# Next.js boilerplate with Prisma

> Prisma 7 ORM on the driver adapter for your database, with a client that survives hot reload. The schema is slotted, so every other battery writes its tables into it. Committed SQL migrations and a seed script are included.

Schema-first Postgres ORM with generated types, real migrations and a GUI.

- **Category:** ORM
- **Pricing:** Prisma ORM, CLI, migrations and Studio are free and open source (Apache 2.0). Prisma's hosted products (Prisma Postgres, the Accelerate cache) have a free plan, then usage-based paid plans from $10/month.
- **Best for:** Teams who want one declarative schema file as the source of truth. You get a migration history you can read in review, and a client whose types you never hand-write. Strong pick when several people touch the data model, or when non-backend contributors need Studio to look at rows.
- **Requires:** database
- **Conflicts with:** drizzle
- **Vendor docs:** https://www.prisma.io/docs

## Trade-offs

- One more schema language to learn. `schema.prisma` is not TypeScript, so codegen and a generate step sit between you and your types. That is the price of the ergonomics.
- A generate step you can forget. Edit the schema without running `bun run db:generate` and the client's types still describe the old shape. The error points at your call site, not the schema.
- Serverless needs a pooler. On Vercel, point `DATABASE_URL` at your database's pooled endpoint for the app. The CLI finds the direct one for migrations through `prisma.config.ts`.
- No Rust engine at runtime. Prisma 7 plans queries in TypeScript and sends them through a driver adapter for your database, so the app bundle is lighter than Prisma 6's. The CLI still downloads a schema engine binary for migrations.
- Most SQL you need has a first-class API. The rest goes through `$queryRaw`, which is less fluent than a SQL-shaped builder.

## Known fixes it ships

- [Prisma types are wrong after a schema edit: generated client drift](https://agenticboilerplate.com/cookbook/prisma/client-drift-after-schema-edit): The Prisma client is generated code. Edit the schema without regenerating and TypeScript describes the old database, locally, in CI-free builds and after a cached deploy.
- [Prisma in dev: "too many clients already" after a few saves](https://agenticboilerplate.com/cookbook/prisma/hot-reload-client-leak): Next.js hot reload re-runs your module and builds a new PrismaClient every time. Cache one instance on globalThis and the connection leak stops.
- [Running Prisma migrations on Vercel without breaking production](https://agenticboilerplate.com/cookbook/prisma/migrate-deploy-on-vercel): Put prisma generate and prisma migrate deploy in the Vercel build command, never db push or migrate dev, and design migrations to survive a rolling deploy.
- [Fixing N+1 queries in Prisma with include, select and groupBy](https://agenticboilerplate.com/cookbook/prisma/n-plus-one-with-include): A loop that queries per row turns one page load into hundreds of round trips. Fetch relations in the parent query, batch by id, and aggregate in the database.
- [Prisma on serverless: why you need a pooler URL and a direct URL](https://agenticboilerplate.com/cookbook/prisma/serverless-connection-pooling): Each serverless instance opens its own Postgres pool, so traffic exhausts connections. Route runtime queries through a pooler and keep a direct URL for migrations.

## Generate it

[Build a repo with Prisma](https://agenticboilerplate.com/build?b=prisma)

---

Agentic Boilerplate: A Next.js repo your agent already knows. Free during launch, then $99 once.

- Site map for agents: https://agenticboilerplate.com/llms.txt
- Public API: https://agenticboilerplate.com/openapi.json
- Contact: agenticstudio@gmail.com
