Next.js 16 + Prisma ORM + PostgreSQL
Production guidelines for Next.js App Router, Server Actions, Prisma connection pooling, PgBouncer/Neon tuning, and Zod schema validation.
- Formats
- 4 files
- AGENTS.md
- 56 lines
- CLAUDE.md
- 17 lines
- Languages
- TypeScript
- Updated
- Oct 2026
- Used by
- 4 projects
Writes .claude/skills/nextjs-prisma-postgres/SKILL.md
$ curl -s --create-dirs -o .claude/skills/nextjs-prisma-postgres/SKILL.md https://stackitfast.com/rules/nextjs-prisma-postgres/SKILL.mdRule files
Works with Cursor · Claude Code · Windsurf · AGY
Architecture notes
Architecture Overview
Production conventions for building high-scale full-stack applications with Next.js 16 App Router, Prisma ORM, and PostgreSQL.
Verified Real-World Adoption
This exact architecture is deployed in production by top open-source platforms including Cal.com, Documenso, Papermark, Typebot, Formbricks, and Umami.
Key Architectural Nuances
- Serverless Connection Management: Using
globalThissingleton client prevents Lambda / HMR connection pool leakage. - Migration Isolation: Separating
DATABASE_URL(pooled port 6543) fromDIRECT_URL(migration port 5432) ensures atomic DDL schema updates.
Frequently asked questions
Does this AGENTS.md work with Cursor, Claude Code, and Windsurf?
Yes — AGENTS.md is the open, cross-tool standard read by Cursor, Claude Code, Windsurf, and 30+ other agents. A dedicated .mdc file is also included for Cursor's native .cursor/rules format.
Why does Prisma need a globalThis singleton in Next.js?
Next.js hot module reloading re-executes module code on every save in development, and without caching the client on globalThis, each reload would instantiate a new PrismaClient and open a fresh connection pool. Left unchecked this exhausts the database's max_connections within a few dozen saves during a normal dev session.
Why use prisma migrate deploy instead of db push in production?
db push directly syncs your schema to the database with no migration history, no rollback path, and no review artifact — it's designed for rapid prototyping, not production changes. migrate deploy applies pre-generated, reviewable SQL migration files in order, giving you an auditable history and the ability to roll back a specific change.
Used in production
Explore all stacksCal.com
1Splitting the tRPC-based web app from an independently versioned NestJS Platform API lets Cal.com serve both its own product and third-party developers from one monorepo, while Turborepo and per-integration app-store packages keep dozens of calendar/payment providers buildable and testable in isolation.
tRPC
tRPC connects backend procedure implementations directly to frontend React hooks with zero-boilerplate type inference.
Prisma
Declarative schema modeling combined with modular driver adapters allows Prisma to generate fully type-safe database clients that run consistently from Node servers to edge runtimes.
Next.js
Performance-critical compilation and bundling are implemented as Rust crates (Turbopack, SWC transforms) compiled to native addons, while the framework surface stays in TypeScript, letting Next.js run its full test matrix across three interchangeable bundlers without forking the codebase.