
Prisma 8 NeonDB Setup for Next.js 16 - PrismaClient Is Gone
Skilldham
Engineering deep-dives for developers who want real understanding.
Last updated: November 2026
TL;DR
Prisma 8 NeonDB setup no longer uses PrismaClient or a driver adapter.
You write src/prisma/contract.prisma and emit it. Then you build db with postgres({ contract, url }). Neon’s pooled URL goes in db.ts, and the direct URL goes in prisma.config.ts.
prisma generate is now prisma contract emit
findMany is now .where().all()
Not ready to move? Install prisma@prev and stay on Prisma 7
You ran npm i prisma on a Next.js project. Nothing else changed.
Then npx prisma generate failed:
bash
# Output of npx prisma generate on prisma 8.0.0-rc.33
✘ [CLI.UNKNOWN_COMMAND] No command registered for `generate`You open your editor. Your @prisma/adapter-neon import is red. You ask an AI tool, and it hands back new PrismaClient({ adapter }) again.
That is Prisma 7 code. It will not run here. Neither will the Neon guide you bookmarked last month.
Here is what happened. Since early November 2026, the latest npm tag for prisma points to 8.0.0-rc.33. You got Prisma 8 without choosing it.
This post is the full Prisma 8 NeonDB setup for Next.js 16.4. Every snippet below runs on Prisma 8.0.0-rc.33 and Postgres 16.
Why npm i prisma Gave You Prisma 8
The CLI and the client now sit on different npm tags. Nobody announced it in your terminal.
The npm Tag That Moved
I checked the registry on November 10, 2026. Here is what it returned.
bash
# npm view prisma dist-tags (trimmed)
latest: 8.0.0-rc.33
prev: 7.10.1
# npm view @prisma/client dist-tags (trimmed)
latest: 7.10.1An unpinned npm i prisma now pulls the release candidate. Your @prisma/client stays on 7.10.1. The two halves no longer match.
Staying on Prisma 7 on Purpose
Not ready for an RC in production? Pin both packages. The Prisma ORM release status page names these exact tags.
bash
# Stay on Prisma 7 - pin the CLI and the client
npm i -D prisma@prev
npm i @prisma/client@7Your old setup keeps working after this. The Prisma 7 NeonDB driver adapter setup still applies line for line.
Only here for the generate error? Read why prisma generate stopped working in Prisma 8. The rest of this post moves forward.

What Is Gone in the Prisma 8 NeonDB Setup
Prisma 8 is a ground-up TypeScript rewrite. The Prisma 8 NeonDB setup shares almost nothing with version 7.
PrismaClient and Driver Adapters
There is no generated PrismaClient in Prisma 8. There is no @prisma/adapter-neon either.
typescript
// Wrong: Prisma 7 code - none of these work with Prisma 8
import { PrismaClient } from "@prisma/client";
import { PrismaNeon } from "@prisma/adapter-neon";
const adapter = new PrismaNeon({
connectionString: process.env.DATABASE_URL,
});
export const prisma = new PrismaClient({ adapter });The runtime now lives in @prisma/orm-postgres. It takes a URL, a pg.Pool, or a pg.Client. Under the hood it is node-postgres 8.22.0 over TCP.
So there is no Neon adapter to install. You connect to Neon like any other Postgres server.
The CLI and Query API Changed Too
This is where AI-written code breaks. Every model trained before Prisma 8 still writes findMany, $transaction, and prisma generate.
All three fail on the RC. The full rename table is near the end of this post.
Step 1 - Write contract.prisma and prisma.config.ts
Prisma 8 splits the old schema.prisma job across two files. One describes your data. The other tells the CLI where the database is.
The Contract Replaces schema.prisma
Your models now live in src/prisma/contract.prisma. Keep the version line at the top.
prisma
// use prisma-8
// File: src/prisma/contract.prisma
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
createdAt DateTime @default(now()) @onCreate(now())
updatedAt temporal.UpdatedAt
}
model Post {
id Int @id @default(autoincrement())
title String
views Int @default(0)
author User @relation(fields: [authorId], references: [id])
authorId Int
createdAt DateTime @default(now()) @onCreate(now())
updatedAt temporal.UpdatedAt
}Notice @onCreate(now()) and temporal.UpdatedAt. In Prisma 8, @default is a database default only. Values the client fills in use @onCreate and @onUpdate.
prisma.config.ts Uses the Direct URL
The CLI reads its connection from prisma.config.ts. Point it at Neon’s direct URL, not the pooler.
typescript
// Correct: prisma.config.ts - the CLI uses the direct Neon URL
import "dotenv/config";
import { definePrismaConfig } from "prisma/config";
import { defineConfig as ormConfig } from "@prisma/orm-postgres/config";
export default definePrismaConfig({
orm: ormConfig({
contract: "./src/prisma/contract.prisma",
db: {
connection: process.env.DIRECT_URL!,
},
}),
});Migrations run DDL and track state in their own schema. Neon recommends its direct endpoint for schema changes. Your app traffic uses the pooled URL in db.ts instead.
The create-prisma scaffold also adds Prisma Composer and Compute blocks. You do not need them on Vercel, so I removed both.
The .env File the CLI Ignores
This one throws a confusing error. Without import "dotenv/config", the CLI never reads your .env file.
bash
# Output of npx prisma migration status without the dotenv import
✘ [CONFIG.DB_CONNECTION_REQUIRED] Database connection is requiredThe scaffold expects exported shell variables. Run npm i -D dotenv and keep that import on line one.
bash
# .env - both URLs come from the Neon dashboard
DATABASE_URL="postgresql://neondb_owner:PASSWORD@ep-example-123456-pooler.us-east-2.aws.neon.tech/neondb?sslmode=verify-full"
DIRECT_URL="postgresql://neondb_owner:PASSWORD@ep-example-123456.us-east-2.aws.neon.tech/neondb?sslmode=verify-full"The only difference is -pooler in the hostname. That suffix sends you through Neon’s PgBouncer.
Step 2 - The Prisma 8 db.ts for Neon
This file is the heart of the Prisma 8 NeonDB setup. The official Next.js guide never shows a standalone version of it.
What Breaks With the Scaffold db.ts
The scaffold file loads a Composer service before it falls back to DATABASE_URL.
typescript
// Wrong for Vercel + Neon: trimmed from the create-prisma scaffold
import service from "../../service.ts";
function loadComposerDatabase() {
try {
return service.load().database.client;
} catch {
return undefined;
}
}
export const db =
loadComposerDatabase() ??
postgres({ contract, url: process.env.DATABASE_URL });On Vercel there is no Composer service to load. Worse, next dev re-runs this module on every hot reload. Each reload opens a fresh pool against Neon.
The Correct db.ts With a Dev Singleton
typescript
// Correct: src/prisma/db.ts - Prisma 8 runtime on Neon's pooled URL
import "temporal-polyfill/global";
import postgres from "@prisma/orm-postgres/runtime";
import { contractFromJson } from "@prisma/orm-postgres/static";
import type { Contract } from "./contract.d.ts";
import contractJson from "./contract.json" with { type: "json" };
export const contract = contractFromJson<Contract>(contractJson);
function createDb() {
return postgres({
contract,
url: process.env.DATABASE_URL!,
poolOptions: {
connectionTimeoutMillis: 10_000,
idleTimeoutMillis: 10_000,
},
});
}
const globalForDb = globalThis as unknown as {
prismaDb?: ReturnType<typeof createDb>;
};
export const db = globalForDb.prismaDb ?? createDb();
if (process.env.NODE_ENV !== "production") {
globalForDb.prismaDb = db;
}Name Contract once, on contractFromJson. The postgres() call takes no type argument. The JSON import needs the with { type: "json" } attribute.
The client connects lazily. Importing db.ts opens nothing until the first query. The globalThis cache keeps one pool alive across next dev reloads.
When DATABASE_URL Is Missing
If the variable is empty at runtime, the first query fails with a driver error. It does not mention the URL at all.
bash
# First query with DATABASE_URL unset
Error [RuntimeError]: Postgres driver not connected. Call connect(binding) before acquireConnection or execute.
code: 'DRIVER.NOT_CONNECTED',Check .env.local locally and your Vercel env settings in production. Scripts run with tsx do not load .env on their own.
The SSL Warning in Your Logs
Neon’s dashboard copies URLs with sslmode=require&channel_binding=require. With pg 8.22.0 you get this on boot:
bash
# Node warning printed by pg-connection-string
Warning: SECURITY WARNING: The SSL modes 'prefer', 'require', and 'verify-ca' are treated as aliases for 'verify-full'.That warning comes from node-postgres, not Prisma. Write sslmode=verify-full and it goes away.
Also, pg 8.22.0 ignores channel_binding in the URL. It only reads enableChannelBinding from code, so you can drop the parameter.
Step 3 - Create Your Tables on Neon
There is no migrate dev anymore. The Prisma 8 NeonDB setup uses smaller, more explicit commands.
First Run With db init
For a fresh Neon branch, emit the contract, then apply it.
bash
# Emit types, then create tables through DIRECT_URL
npx prisma contract emit
npx prisma db initcontract emit writes contract.json and contract.d.ts. It is the new prisma generate. db init creates the tables and signs the database.
bash
# npx prisma db init output (trimmed)
├─ Create table "User"
├─ Add unique constraint on "User" (email)
├─ Add foreign key "Post_authorId_fkey" on "Post"
└─ marker 920a87b5...Schema Changes After That
Change the contract, then plan and apply a migration.
bash
# Replaces prisma migrate dev and prisma migrate deploy
npx prisma contract emit
npx prisma migration plan --name add-views
npx prisma db migrate`migration plan` prints the DDL before it writes anything:
sql
-- DDL preview printed by prisma migration plan
ALTER TABLE "public"."Post" ADD COLUMN "views" int4 DEFAULT 0 NOT NULL;Next.js has no Prisma 8 plugin yet. Add "prebuild": "prisma contract emit" to your scripts so Vercel builds fresh types.
The Marker Table You Should Not Delete
Prisma 8 adds a prisma_contract schema to your Neon database. It holds marker, ledger, and contract tables.
The runtime reads the marker on the first query. If the database is unreachable then, you get CONTRACT.MARKER_READ_FAILED. That error leads straight into the next trap.
Step 4 - Query Neon From a Next.js 16 Server Component
The query API is a chain now. Models sit under their Postgres schema, so User lives at db.orm.public.User.
The Prerender Trap
Take a plain server component and run `next build` on Next.js 16.4.2.
tsx
// Wrong: no dynamic opt-out, so Next.js prerenders this at build time
import { db } from "../../prisma/db";
export default async function PostsPage() {
const posts = await db.orm.public.Post
.select("id", "title", "views")
.orderBy((p) => p.views.desc())
.limit(10)
.all();
return (
<ul>
{posts.map((p) => (
<li key={p.id}>
{p.title} - {p.views}
</li>
))}
</ul>
);
}The build marked the route as static. It queried the database during the build and froze those rows into HTML.
Remove `DATABASE_URL` from the build env, and the build crashes instead:
bash
# next build output when the build cannot reach the database
Error occurred prerendering page "/neon".
Error [CliStructuredError]: Database error while reading contract marker
code: 'CONTRACT.MARKER_READ_FAILED',The Fix - Render on Each Request
tsx
// Correct: render per request so Neon is queried at runtime
import { db } from "../../prisma/db";
export const dynamic = "force-dynamic";
export default async function PostsPage() {
const posts = await db.orm.public.Post
.select("id", "title", "views")
.orderBy((p) => p.views.desc())
.limit(10)
.all();
return (
<ul>
{posts.map((p) => (
<li key={p.id}>
{p.title} - {p.views}
</li>
))}
</ul>
);
}With that one line, the route builds as dynamic. IRebuild with no `DATABASE_URL` at all, and it passes. The official scaffold uses the same line on its home page.
Deploying the Prisma 8 NeonDB Setup on Vercel
Vercel Fluid compute reuses one function instance for many requests. That changes how you handle the pool.
Hand Vercel Your Own Pool
Idle pool clients can leak when an instance suspends. attachDatabasePool from @vercel/functions closes them cleanly. Prisma 8 accepts your own pg.Pool through the pg option, so you can attach it.
typescript
// Correct: src/prisma/db.ts on Vercel - your pool, attached to Fluid compute
import "temporal-polyfill/global";
import pg from "pg";
import { attachDatabasePool } from "@vercel/functions";
import postgres from "@prisma/orm-postgres/runtime";
import { contractFromJson } from "@prisma/orm-postgres/static";
import type { Contract } from "./contract.d.ts";
import contractJson from "./contract.json" with { type: "json" };
export const contract = contractFromJson<Contract>(contractJson);
function createDb() {
const pool = new pg.Pool({
connectionString: process.env.DATABASE_URL,
max: 5,
idleTimeoutMillis: 5_000,
connectionTimeoutMillis: 10_000,
});
attachDatabasePool(pool);
return postgres({ contract, pg: pool });
}
const globalForDb = globalThis as unknown as {
prismaDb?: ReturnType<typeof createDb>;
};
export const db = globalForDb.prismaDb ?? createDb();
if (process.env.NODE_ENV !== "production") {
globalForDb.prismaDb = db;
}This uses `@vercel/functions` 3.11.1. Outside Vercel, the call is harmless in local scripts. I covered the same pattern for MongoDB in attachDatabasePool on Vercel.
The pg option also unlocks max. Prisma 8’s own poolOptions only exposes the two timeouts. Keep max small, because Neon’s pooler handles the real fan-out.
Pool sizing on serverless has its own traps, covered in Prisma pool timeouts on serverless.
Never Call db.close() in a Handler
db.close() is terminal. After it, every query rejects with Postgres client is closed.
typescript
// Wrong: closes the shared pool after the first request
import { db } from "../../../prisma/db";
export async function GET() {
const users = await db.orm.public.User.limit(20).all();
await db.close();
return Response.json(users);
}typescript
// Correct: src/app/api/users/route.ts - reuse the singleton, never close it
import { db } from "../../../prisma/db";
export const dynamic = "force-dynamic";
export async function GET() {
const users = await db.orm.public.User.limit(20).all();
return Response.json(users);
}Servers keep the pool open for the life of the instance. Use db.close() only in scripts and seeds. If you passed your own pool, db.close() leaves it open, so call pool.end() too.
typescript
// Correct: scripts/seed.ts - close at the end so Node can exit
import { db } from "../src/prisma/db";
await db.orm.public.User.create({ email: "seed@example.com", name: "Seed" });
await db.close();Keep these routes on the Node.js runtime. Prisma 8 has a separate postgresServerless() client for edge runtimes. This post does not cover it.
Prisma 7 to Prisma 8 Rename Table
This is the table I wish I had on day one. EEvery Prisma 8 line below runs on rc.33. Prisma’s official Coming from Prisma ORM 7 page has the full mapping.
Commands, Reads, and Writes
Prisma 7Prisma 8 RCprisma generateprisma contract emitprisma migrate devprisma migration plan then prisma db migrateprisma migrate deployprisma db migratenew PrismaClient({ adapter })postgres({ contract, url })prisma.user.findMany({ where, orderBy, take })db.orm.public.User.where(...).orderBy(...).limit(n).all()findUnique({ where: { id } }).first({ id })findFirst({ where }).where({ ... }).first()create({ data }).create({ ... })update({ where, data }).where({ ... }).update({ ... })delete({ where }).where({ ... }).delete()include: { posts: true }.include("posts")_count: { select: { posts: true } }.include("posts", (p) => p.count())prisma.user.count().aggregate((a) => ({ total: a.count() }))$transaction(async (tx) => ...)db.transaction(async (tx) => ...)$disconnect()db.close()
Paste Prisma 7 calls into a Prisma 8 project and TypeScript tells you fast:
bash
# tsc output when Prisma 7 calls hit the Prisma 8 client
error TS2339: Property 'findMany' does not exist on type 'Collection<...>'.
error TS2339: Property '$extends' does not exist on type 'PostgresClient<...>'.
error TS2551: Property '$transaction' does not exist on type 'PostgresClient<...>'. Did you mean 'transaction'?
error TS2322: Type '{ increment: number; }' is not assignable to type 'number'.The Gaps That Block Migration
Three Prisma 7 habits have no direct match yet.
{ increment: 1 } is a type error on update.
$extends is gone. Custom collection classes and middleware replace parts of it.
The array form $transaction([a, b]) is gone. Use the callback form.
Here is the increment workaround through the raw SQL lane:
typescript
// Correct: atomic increment through Prisma 8's raw SQL lane
import { db } from "../prisma/db";
export async function addView(postId: number) {
await db.execute(
db.raw.sql`UPDATE "Post" SET "views" = "views" + 1 WHERE "id" = ${postId}`
.affectedCount()
.build(),
);
}Fire 21 of these at one row, 20 in parallel. The counter lands on exactly 21. The ${postId} value goes in as a bound parameter, not pasted SQL.
Does your app lean on $extends for soft deletes or computed fields? Then wait for GA before you migrate.
Key Takeaways
The Prisma 8 NeonDB setup has no PrismaClient and no Neon adapter. You call postgres({ contract, url }).
An unpinned npm i prisma installs 8.0.0-rc.33 today. Pin prisma@prev and @prisma/client@7 to stay on 7.
Put Neon’s direct URL in prisma.config.ts and the -pooler URL in db.ts.
Add import "dotenv/config" to prisma.config.ts, or the CLI cannot see your .env.
Cache db on globalThis in development so next dev keeps one pool.
Add export const dynamic = "force-dynamic" to pages that query Neon. Otherwise the build prerenders them.
Never call db.close() inside a route handler on Vercel.
Use the raw SQL lane for atomic increments until the ORM supports them.
Frequently Asked Questions
Why does npm i prisma install Prisma 8 now?
The latest tag on the prisma package points to 8.0.0-rc.33. The @prisma/client package still has 7.10.1 as latest. Any unpinned install of the CLI now gets the release candidate.
How do I stay on Prisma 7 with NeonDB?
Run npm i -D prisma@prev and npm i @prisma/client@7. Prisma 7 stays fully supported. Your existing driver adapter code keeps working with no changes.
Does Prisma 8 work with Neon’s serverless driver?
Prisma 8 has no Neon driver adapter. Its runtime talks to Postgres through node-postgres over TCP. Use Neon’s pooled TCP URL from the Node.js runtime instead.
What replaced prisma generate in Prisma 8?
prisma contract emit replaced it. It writes contract.json and contract.d.ts next to your contract. Running prisma generate on Prisma 8 fails with No command registered for generate.
Should Prisma 8 use the pooled or direct Neon URL?
Use both. The CLI runs migrations through the direct URL in prisma.config.ts. Your app queries through the -pooler URL in db.ts.
Do I still need a database singleton in Next.js 16?
Yes, in development. next dev re-runs your modules on every hot reload. Caching db on globalThis stops each reload from opening a new pool.
Can I use @prisma/client 7 with the Prisma 8 CLI?
No. The Prisma 8 CLI has no generate command, so it cannot build a version 7 client. Pin both packages to version 7, or move fully to version 8.
Is Prisma 8 ready for production on Neon?
Not yet. It is still a release candidate, and the APIs changed between RC builds. Test your Prisma 8 NeonDB setup on a Neon branch first.
Conclusion
Prisma 8 replaces the generated client with a contract and a plain postgres() factory. Once you know that, the Prisma 8 NeonDB setup is just two URLs and one db.ts.
The real risk is not the new API. It is shipping half-migrated code that an AI tool or an unpinned install handed you.
Vercel deploy still failing? The Next.js build fails on Vercel guide covers the env variable cases.
Prisma 8 GA is close, and I will update this post when it lands. Subscribe to the SkillDham newsletter to get the update the day it ships.