Zero runtime dependencies
Just pg as a peer dependency. No Redis, no extra services - use the Postgres you already have.
import { Pool } from "pg";import { Ratelimit } from "pg-ratelimit";
const pool = new Pool();const ratelimit = new Ratelimit({ pool, prefix: "api", limiter: Ratelimit.fixedWindow(10, "60s"),});
const { success } = await ratelimit.limit("user:123");if (!success) { return new Response("Too Many Requests", { status: 429 });}Zero runtime dependencies
Just pg as a peer dependency. No Redis, no extra services - use the Postgres you already have.
Three algorithms
Fixed window, sliding window, and token bucket. Pick the right tradeoff for your use case.
Serverless-safe
No background processes or singletons. Probabilistic inline cleanup with no long-lived state. Works in Lambda, Vercel, and other serverless platforms.
Upstash-compatible API
Same limit(), blockUntilReady(), getRemaining(), and resetUsedTokens() surface. Migrate
with minimal code changes.
Most rate limiting libraries require Redis or a dedicated service. If you already run PostgreSQL, you already have everything you need.
pg. No Redis, no sidecars, no new thing to monitor.