Skip to main content

Upstash Rate Limit

npm (scoped) It is the only connectionless (HTTP based) rate limiting library and designed for:
  • Serverless functions (AWS Lambda, Vercel …)
  • Cloudflare Workers
  • Vercel Edge
  • Fastly Compute@Edge
  • Next.js, Jamstack …
  • Client side web/mobile applications
  • WebAssembly
  • and other environments where HTTP is preferred over TCP.

Features

Caching

Handle blocked requests without having to call your Redis Database

Timeout

If the Redis call of the ratelimit is not resolved in some timeframe, allow the request by default

Analytics & Dashboard

Collect information on which identifiers made how many requests and how many were blocked

Traffic Protection

Create a deny list to block requests based on user agents, countries, IP addresses and more

Custom Rates

Consume different amounts of tokens in different requests (example: limiting based on request/response size)

Multi Region

Utilize several Redis databases in different regions to serve users faster

Multiple Limits

Use different limits for different kinds of requests (example: paid and free users)

Dynamic Limits

Change rate limits at runtime without recreating the rate limiter instance
For more information about the features, see the Features tab.

Examples

Nextjs

Rate limit an API in a Nextjs project

Nextjs with Middleware

Rate limit an API with a Middleware in a Nextjs project

Vercel Edge

Rate limit an Vercel Edge Function

Enabling Protection

Use Deny Lists to Protect Your Website

Cloudflare Pages

Rate limit access to your Cloudflare Pages app

Cloudflare Workers

Rate limit access to your Cloudflare Workers

Remix

Rate limit access to a Remix App

Rate limit using Vercel KV

Rate limit a Nexjs app using Vercel KV

Deno App

Rate limit your deno app

Rate limit your Chatbot

Limiting requests to a Chatbot endpoint which streams LLM outputs