Error library

Prisma Client on the edge runtime / bundled for the browser

Prisma Client was bundled into client code or run in an edge runtime that cannot open normal database connections. Keep Prisma in Node.js server code (export const runtime = 'nodejs'), or use an edge-compatible driver adapter or Prisma Postgres/Accelerate if you must run at the edge.

Cause: A route, middleware, or client component imports Prisma while running on the Edge runtime or in the browser.

How to fix it

  1. Remove export const runtime = 'edge' from routes that use Prisma (Node.js is Vercel's default).
  2. Don't import Prisma in client components or middleware; call it from server code only.
  3. For edge, use a supported driver adapter (e.g. Neon serverless) or Prisma Postgres/Accelerate.
  4. Run prisma generate in the build step and redeploy.

Example

Illustrative example, not from a customer project.

- export const runtime = 'edge'
+ export const runtime = 'nodejs'
  import { prisma } from '@/lib/prisma'

FAQ

Can I use `pg` on Vercel Edge?

Prisma's docs note node-postgres is not supported on Vercel Edge Functions.

Why does middleware trigger it?

Next.js middleware has historically run on the Edge runtime, so importing Prisma there hits this error.

Get a $149 diagnosis See pricing Still exposed or still logged out? Get an auth & database security fix (Supabase, Firebase).

$149Get a $149 diagnosis