Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Add rate limiting to your application with any frontend framework.

Astro landing page starter with gradient background, responsive hamburger/dropdown menu, and switchable floating/fullscreen headers.
Vercel Edge Middleware Rate Limit is a boilerplate template from Vercel that adds rate limiting to any frontend application using Vercel KV and Vercel Edge Middleware, without tying you to a specific framework.
Vercel Edge Middleware Rate Limit is a framework-agnostic template that shows how to enforce rate limits by intercepting requests at the edge before they reach your backend. It accepts HTTP requests to any route in your application and, using Vercel KV as a persistent key-value store, tracks request counts per client. When a client exceeds the configured limit, the middleware responds with a 429 Too Many Requests status, blocking the request while allowing normal traffic to pass.
The template runs on Vercel's edge network, meaning the middleware executes in regions close to the user, reducing added latency. It is published as part of the official Vercel examples repository and is intended as a reference pattern for building robust, scalable applications.
The middleware function runs on every request, reads a client identifier from the request (such as an IP address or API key), and checks the current count stored in Vercel KV. If the count is below the limit, it increments the counter and allows the request through; if the limit is already reached, it returns a 429 response. The counter storage and increments happen atomically in Vercel KV, ensuring accuracy across concurrent requests.
Yes, but Vercel specifically notes that Next.js users should use the built-in middleware support rather than @vercel/edge. The template references a separate Next.js example for that path.
It uses Vercel KV, a key-value database offered by Vercel, which is automatically provisioned when you deploy with the template.
It happens in Vercel Edge Middleware, which runs on Vercel's edge network, so requests are limited before reaching your serverless functions or origin.
Rate limit values are set in the code of the middleware function. You can adjust the maximum number of requests and the time window directly to suit your application.
