Vercel: The Edge Function "middleware" size is 1.2 MB and your plan size limit is 1 MB. Learn More: https://vercel.link/edge-function-size
Your middleware/Edge Function bundle is larger than the plan's size limit.
The Edge Function "middleware" size is 1.2 MB and your plan size limit is 1 MBEdge Function size limit exceeded VercelThe Edge Function size is and your plan size limit is. Learn More: https://vercel.link/edge-function-sizeError: The Edge Function middleware size is too big Meaning
Reduce imports in middleware: avoid heavy libraries, import only what you need, move logic to Node routes, and check the bundle with @next/bundle-analyzer. Hobby 1 MB, Pro 2 MB, Enterprise 4 MB (compressed). Tree-shake and replace big deps (lodash → native).
Common causes
- Heavy libraries imported in middleware
- Shared utils pulling in large dependencies
- i18n/auth libs bundled entirely
- Unused code not tree-shaken
- Many matchers with large logic
⚡ Quick fix
- Keep middleware minimal; import small modules only
- Move heavy logic to route handlers
- Analyze the bundle and remove large dependencies
Detailed fix by platform
Next.js
ANALYZE=true next buildwith@next/bundle-analyzer
How to diagnose
- Size — Bundle vs limit?
- Imports — What is heavy?
- Logic — Needs Edge?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Dynamic Code Evaluation not allowed in Edge Runtime Next.js: Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime
- next build: fetch failed ECONNREFUSED (build-time API) Next.js: Error occurred prerendering page "/blog" TypeError: fetch failed { cause: Error: connect ECONNREFUSED 127.0.0.1:3000 }
- Prisma Client out of date on Vercel (prisma generate) Vercel: PrismaClientInitializationError: Prisma has detected that this project was built on Vercel, which caches dependencies. This leads to an outdated Prisma Client
Most viewed in Next.js
- NEXT_REDIRECT Next.js: Error: NEXT_REDIRECT (redirect() inside try/catch)
- server-only Next.js: You're importing a component that needs "server-only". That only works in a Server Component
- cookies() should be awaited Next.js 15: Route "/x" used `cookies().get('token')`. `cookies()` should be awaited before using its value
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026