Next.js 16 + Drizzle ORM + Supabase
Production guidelines for Next.js App Router, Drizzle ORM with postgres-js, Supabase Transaction Pooler (prepare: false), and RLS security.
- Formats
- 4 files
- AGENTS.md
- 59 lines
- CLAUDE.md
- 16 lines
- Languages
- TypeScript
- Updated
- Oct 2026
- Used by
- 4 projects
Writes .claude/skills/nextjs-drizzle-supabase/SKILL.md
$ curl -s --create-dirs -o .claude/skills/nextjs-drizzle-supabase/SKILL.md https://stackitfast.com/rules/nextjs-drizzle-supabase/SKILL.mdRule files
Works with Cursor · Claude Code · Windsurf · AGY
Architecture notes
Architecture Overview
Standardized production guidelines for Next.js 16 App Router, Drizzle ORM, and Supabase PostgreSQL.
Verified Real-World Adoption
Utilized by modern high-velocity platforms like Supabase Studio, Dub.co, and CopilotKit.
Key Architectural Nuances
- Prepared Statement Disabling: Supabase’s transaction pooler requires
prepare: falseto prevent statement naming collisions across ephemeral Lambda invocations. - Relational Query Builder: Combines SQL performance with declarative, type-safe nested object queries.
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 Supabase's transaction pooler require prepare: false?
PgBouncer's transaction pooling mode reassigns the underlying Postgres connection after every transaction, but prepared statements are tied to a specific connection. When postgres-js tries to reuse a prepared statement name on a connection that doesn't have it, Postgres throws a 'prepared statement already exists' or 'does not exist' error — disabling prepared statements avoids the mismatch entirely.
Why use a globalThis singleton for the Drizzle client instead of creating it per request?
Next.js hot module reloading in development re-executes module-level code on every file save, which would otherwise open a fresh Postgres connection each time and quickly exhaust the connection pool. Caching the client on globalThis in development ensures the same connection is reused across HMR reloads.
Used in production
Explore all stacksSupabase Studio
1Centering the developer experience around PostgreSQL allows Supabase Studio to provide spreadsheet-like table editing and SQL execution directly on production databases.
Payload CMS
A pnpm and Turborepo monorepo lets one core package share a common database-adapter export shape across MongoDB, Postgres, SQLite, and D1, while GraphQL, storage providers, and deployment templates stay in separate packages so a project only pulls in the pieces its target host and database actually need.
shadcn/ui
Distributing components as source code gives developers full ownership and customization freedom while pairing Radix accessibility with Tailwind utility styling.
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.