guide
A complete, server-first guide to using Prisma with Next.js 16 App Router, covering setup, schema design, data fetching, and best practices.

Next.js 16 pushes a server-first architecture.
Prisma was built for exactly this:
Together, they eliminate an entire class of bugs.
Start by installing Prisma and the client:
pnpm add prisma @prisma/client
pnpm prisma initThis creates:
prisma/schema.prisma.env with a database URLUpdate your .env file:
DATABASE_URL="postgresql://user:password@localhost:5432/mydb"Prisma works seamlessly with hosted databases like Neon, Supabase, or Railway.
model Post {
id String @id @default(cuid())
title String
content String
published Boolean @default(false)
createdAt DateTime @default(now())
}Prisma schemas are declarative and self-documenting.
// lib/prisma.ts
import { PrismaClient } from "@prisma/client";
const globalForPrisma = globalThis as unknown as {
prisma: PrismaClient | undefined;
};
export const prisma =
globalForPrisma.prisma ?? new PrismaClient();
if (process.env.NODE_ENV !== "production") {
globalForPrisma.prisma = prisma;
}This prevents connection leaks in development.
export async function getPosts() {
return prisma.post.findMany({
where: { published: true },
});
}No API routes required.
export default async function BlogPage() {
const posts = await getPosts();
return (
<ul>
{posts.map((post) => (
<li key={post.id}>{post.title}</li>
))}
</ul>
);
}"use server";
export async function createPost(data: FormData) {
await prisma.post.create({
data: {
title: data.get("title") as string,
content: data.get("content") as string,
},
});
}No API layer needed.
fetch() unnecessarilyPrisma + App Router is the cleanest full-stack DX Next.js has ever had.
I share new articles, insights, and experiments in modern web development. No spam — just useful content.