Add Lume to Vercel in one middleware file
One middleware file, zero added latency, and it works on serverless and edge isolates where the SDK can’t.
Install
1Install @vercel/functions
Add it with npm i @vercel/functions. Lume uses its waitUntil() helper.
2Add the middleware
Drop a middleware.ts at your project root, or merge it into an existing one.
3Set your ingest token
Add LUME_INGEST_TOKEN as an environment variable and redeploy. No token set? Middleware serves traffic normally and reports nothing.
Good to know
- Uses waitUntil() to send the report after the response is on its way: zero latency, fail-open. Reliable on serverless / edge isolates where the SDK’s in-memory flush gets frozen.
- Geo comes from Vercel’s coarse, IP-free geolocation(); the visitor’s IP is deliberately never used, so agents are identified by user-agent + catalog and may show as not IP-verifiable.
- Above ~600 req/min sustained the endpoint returns 429 and excess reports drop into sampling. Narrow the matcher to scope what is reported.
Works with the rest of your stack
Lume is CDN-agnostic and server-side. This is one of several install paths, all feeding the same dashboard. Mix and match across hosts, or move providers without losing your history.
Vercel middleware FAQ
SDK or middleware on Vercel?
Middleware. On Vercel’s serverless / edge isolates the instance can freeze the moment your response returns, dropping the SDK’s batched flush. Middleware + waitUntil is the reliable fire-and-forget path here.
Does it capture response status?
No, middleware runs before your response, so response_status and timing are omitted for this path. Everything else (who, what, where) is captured.
Send your first Vercel middleware event in minutes.
Free plan, one ingest token. See every human, bot, and AI agent, however you install.
Start for free →