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 the 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.

Multiple Limits

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

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
For more information about the features, see the Features tab.

Examples

Cloudflare Workers

Rate limit access to your Cloudflare Workers

Nextjs

Rate limit an API in a Nextjs project using the App router

Nextjs with Middleware

Rate limit an API with a Middleware in a Nextjs project using the Pages router

Remix

Rate limit access to a Remix App

Rate limit using Vercel KV

Rate limit a Nexjs app using Vercel KV

Rate limit your Chatbot

Limiting requests to a Chatbot endpoint which streams LLM outputs