Edge Function size limit exceeded Next.js Origin: On your device Last updated 5 Nov 2026

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.

Exact message you may see 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
Seen on: Next.js

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

  1. Keep middleware minimal; import small modules only
  2. Move heavy logic to route handlers
  3. Analyze the bundle and remove large dependencies

Detailed fix by platform

Next.js

  1. ANALYZE=true next build with @next/bundle-analyzer

How to diagnose

  1. Size — Bundle vs limit?
  2. Imports — What is heavy?
  3. 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:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

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.js)Dynamic Code Evaluati…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 } (Next.js)next build: fetch fai…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 (Next.js)Prisma Client out of …The edge runtime does not support Node.js module — Next.js: The edge runtime does not support Node.js 'crypto' module / A Node.js module is loaded ('fs') which is not supported in the Edge Runtime (Next.js)The edge runtime does…Vercel FUNCTION_INVOCATION_TIMEOUT (504) — Vercel: 504 GATEWAY_TIMEOUT — FUNCTION_INVOCATION_TIMEOUT: An error occurred with your deployment (Next.js)Vercel FUNCTION_INVOC…Vercel FUNCTION_PAYLOAD_TOO_LARGE (413) — Vercel: 413 FUNCTION_PAYLOAD_TOO_LARGE — Request Entity Too Large (4.5 MB limit) (Next.js)Vercel FUNCTION_PAYLO…Vercel: Command "npm run build" exited with 1 — Vercel: Error: Command "npm run build" exited with 1 (Next.js)Vercel: Command "npm …Edge Func…

Explore the map of this error Full error map →

🧠 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.