Next.js · 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 `Chrome`).

What it means

A Client Component imports your database client (often through lib/db.ts). Database code can only run on the server.

Common causes

  • A "use client" component imports db from @/lib/db
  • A shared file exports both db queries and client helpers

How to fix it

  1. Query the database in a Server Component or Server Action and pass the rows down as plain objects
  2. Add import "server-only" to lib/db.ts so the build fails early next time
src/lib/db.ts
import "server-only";
import { PrismaClient } from "@prisma/client";

export const db = new PrismaClient();

works with Next.js 16.4.3 · React 19.3last verified

prevent it · security.mdc (free Cursor Rules Pack): Database modules start with import "server-only", so a client import fails at build time instead of in the browser.

Prompt for Cursor or Claude Code

Prisma is being bundled into the browser. Find which "use client" file imports the database client, move the query into a Server Component or Server Action, and add import "server-only" to the db module.

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

next: skip the next one

Skip the setup. The VibeBoot SaaS Starter gives you auth, Stripe and a database already wired on Next.js 16.4.3, with AGENTS.md and .cursor/rules that keep your agent on the Next.js 16 conventions. $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