# 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

**Code:** `Edge Function size limit exceeded` · **Category:** Next.js · **Seen on:** Next.js

Your middleware/Edge Function bundle is larger than the plan's size limit.

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/nextjs/vercel-edge-function-size-limit)
