A Node.js rate-limiting library using sliding windows stored in Redis. Version 1.8.0 (latest as of 2025) is stable with infrequent updates. It supports multiple rules per instance, whitelisting/blacklisting, and includes Express middleware. Compared to alternatives like express-rate-limit, it relies on Redis for distributed rate limiting and uses a sliding window algorithm for more accurate throttling.
npm install ratelimit.jsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a RateLimit instance with two rules (per-second and per-hour) and checking if a key is rate limited.
Use precision defaults (interval in seconds) or set precision to a lower value (e.g., precision: 100 for 100ms slots).
Use unwhitelist() or unblacklist() to remove entries, or implement TTL via external key expiration.
Wrap incr() calls with error handling and consider implementing a circuit breaker.
Migrate to 1.x by using new RateLimit(client, rules) and calling limiter.incr(key, callback).
Use const { RateLimit } = require('ratelimit.js'); then new RateLimit(...)Ensure Redis is running on localhost:6379 or set REDIS_URL environment variable properly.