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
- Remove
export const runtime = 'edge'from routes that use Prisma (Node.js is Vercel's default). - Don't import Prisma in client components or middleware; call it from server code only.
- For edge, use a supported driver adapter (e.g. Neon serverless) or Prisma Postgres/Accelerate.
- Run
prisma generatein 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).
- Fixed, or we keep working free until it is (within the written scope).
- A human reviews every fix before it ships.
- read-only access; fixes arrive as pull requests you merge
- Your $149 diagnosis is credited in full toward any paid job.