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.
QUICK FIX · $49 · THIS ERROR ONLY
Get this exact error fixed — $49 Quick FixFixed within scope, or we keep working until it is · Read-only access Not sure it's this error? $149 diagnosis
- 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.
One error, one root cause, fixed in your app. If it turns out bigger, we tell you before doing more, and your $49 is credited toward the fix, diagnosis or Launch Path if you book within 14 days. Fixing three? The 3-Error Pack is $119.
Bigger job: More than one auth or data issue? Auth & database security fix, from $400.
Built with Lovable, Bolt, Replit, Cursor or v0? See rescue by platform and the security checklist.