Prisma · browser console

PrismaClient is unable to run in this browser environment

what it looks like
Error: PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in `…`).
If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report

What it means

Prisma Client ended up in JavaScript that runs in the browser. It can only run on the server: it needs your database URL and a server-side engine.

Common causes

  • A "use client" component imports db from lib/db.ts
  • A shared helper file imports Prisma and is also used by a Client Component
  • The agent fixed a hook error by adding "use client" to a page that queries the database

How to fix it

  1. Do the query in a Server Component, Server Action or route handler, and pass plain data to the Client Component as props
  2. Add import "server-only" at the top of lib/db.ts, so any client import fails at build time with a clear message
  3. Split helpers: keep database code in files only the server imports
src/lib/db.ts
import "server-only";
import { PrismaClient } from "@prisma/client";

const globalForPrisma = globalThis as unknown as { prisma?: PrismaClient };
export const db = globalForPrisma.prisma ?? new PrismaClient();
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = db;

works with Prisma ORM 6.19 · Next.js 16last verified

prevent it · security.mdc (free Cursor Rules Pack): Database modules start with import "server-only", so they can't end up in a client bundle.

Prompt for Cursor or Claude Code

Prisma Client is being bundled into browser code. Find the "use client" file (or a helper it imports) that imports db or @prisma/client, move the query into a Server Component or Server Action, and pass plain serializable data down as props. Add import "server-only" to lib/db.ts.

Not quite your error? Paste yours into the free VibeBoot Doctor or browse the Prisma error fixer.

next: skip the next one

Skip the setup. The VibeBoot SaaS Starter ships a ready prisma/schema.prisma and one Prisma client in src/lib/db.ts (SQLite by default, Postgres by changing the provider), plus auth and Stripe on Next.js 16.4.3. $49, one-time.

14-day money-back guarantee · lifetime updates

$ fixed it? get the next one first

New fixes for what AI agents break, by email.

When we add a fix or a Cursor rule for a new Next.js, Auth.js, Prisma or Stripe break, it goes out in the VibeBoot newsletter. Free, occasional, unsubscribe in one click.

Subscribe free