Vercel deployment fails: serverless function exceeds 50MB with Prisma bundled per route
Problem
Deploying a Next.js 14 App Router application to Vercel fails because every serverless function that imports Prisma includes the full Prisma query engine binary, pushing each function over the 50MB unzipped limit. Prisma ships multiple platform-specific engine binaries and by default all are bundled. Setting binaryTargets to only rhel-openssl-3.0.x (the Vercel runtime) and using outputFileTracingExcludes reduces the size dramatically.
Error Output
Error: A Serverless Function has exceeded the unzipped maximum size of 50 MB. Learn More: https://vercel.link/serverless-function-size
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Set Prisma binaryTargets to Vercel runtime only and exclude engine files
Prisma bundles engine binaries for every platform listed in binaryTargets. With the default "native" setting, it includes macOS and Linux binaries. Only the rhel-openssl-3.0.x binary is needed on Vercel.
Trust Score
8 verifications
- 1
Set binaryTargets to only the Vercel runtime
In schema.prisma:
prismagenerator client { provider = "prisma-client-js" binaryTargets = ["native", "rhel-openssl-3.0.x"] } - 2
Exclude Prisma engine files from output tracing
In next.config.mjs:
jsconst nextConfig = { experimental: { outputFileTracingExcludes: { '*': [ 'node_modules/@prisma/engines/**', 'node_modules/.prisma/client/libquery_engine-*', ], }, }, } export default nextConfig - 3
Run next build locally to verify size
Check .next/server/app/ — each route bundle should be well under 50MB.
Validation
Vercel deployment succeeds without function size errors.
Verification Summary
Sign in to verify this fix
Environment
- Product
- Vercel + Next.js + Prisma
- Version
- Next.js 14
- Environment
- production
Submitted by
Alex Chen
2450 rep