Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Template featuring IP Blocking at the edge using Upstash.
IP Blocking with Upstash is a Next.js boilerplate from Vercel's examples repository that demonstrates how to block IP addresses at the edge using Upstash Redis. It runs on Vercel's Edge Middleware, so IP checks happen before requests reach your origin server. The template is part of Vercel's edge middleware collection, alongside related examples like Bot Protection with Botd and IP Blocking with DataDome.
IP Blocking with Upstash is an open-source example that shows how to enforce an IP blocklist in Redis at the edge. Built on Next.js, it uses Upstash's REST API to store and query blocked IPs, and it ships with a one-click Vercel deployment link that pre-configures the required environment variables. The template is maintained as part of the Vercel examples repository and includes a live demo at edge-functions-ip-blocking.vercel.app.
UPSTASH_REST_API_DOMAIN and UPSTASH_REST_API_TOKEN.pnpm create next-app --example and run pnpm dev for a local development server.First, create an Upstash account and a Redis database. Then copy the .env.example file to .env.local, fill in UPSTASH_REST_API_DOMAIN and UPSTASH_REST_API_TOKEN with your database credentials, and run pnpm dev. The middleware will query Upstash for each incoming request's IP and block matches.
Yes, the template requires Upstash because it stores the IP blocklist in Upstash Redis and communicates via the Upstash REST API.
You can use the one-click deploy link in the repository to clone and deploy immediately. The link sets the environment variables and project names for you, or you can clone the repo and deploy manually from your Vercel dashboard.
The code is written specifically against Upstash's REST API, so switching providers would require modifying the middleware to use another client or HTTP interface.
The demo URL is https://edge-functions-ip-blocking.vercel.app; availability depends on Vercel hosting and may change, but it is the official demo referenced in the repository.
The repository lists related edge middleware examples: Bot Protection with Botd, Bot Protection with DataDome, and IP Blocking with DataDome. These cover different services and use cases.
