Universal Rate Limiter

npm version

Modern, TypeScript-first rate limiting that works everywhere. No Redis required. Zero dependencies. Built for the edge.

Install
npm install universal-rate-limiter
# or
pnpm add universal-rate-limiter
# or
yarn add universal-rate-limiter
# or
bun add universal-rate-limiter

Works Everywhere You Need It

One library, every JavaScript runtime. From browsers to serverless.

Universal

Browser, Node.js, Edge, Serverless - works everywhere JavaScript runs

Zero Dependencies

No external packages. Lightweight and tree-shakeable for minimal bundle size

TypeScript First

Fully typed with excellent IntelliSense support and type safety

Pluggable Storage

Memory, localStorage, or bring your own adapter. Flexible and extensible

Quick Start

Get up and running in seconds with our simple API

example.ts
1import { createRateLimiter, MemoryStorage } from 'universal-rate-limiter';
2
3const limiter = createRateLimiter({
4  key: 'api-requests',
5  max: 10,
6  window: '1m',
7  storage: new MemoryStorage()
8});
9
10const result = await limiter.check();
11if (result.allowed) {
12  // Process the request
13  console.log(`Remaining: ${result.remaining}`);
14} else {
15  console.log(`Rate limited. Retry after ${result.retryAfter}ms`);
16}

Perfect For Any Use Case

API Protection

Protect your REST or GraphQL APIs from abuse

Express Middleware

Drop-in middleware for Express applications

Next.js Edge

Rate limiting at the edge with Next.js middleware

Form Submissions

Prevent spam on contact forms and sign-ups

Client-Side Actions

React hook for limiting user interactions

Serverless Functions

Works seamlessly with AWS Lambda, Vercel, etc.

Ready to get started?

Install universal-rate-limiter and start protecting your applications in minutes