Installation
Requirements, entry points, and supported Redis clients.
Requirements
- Node.js 20 or later. The core uses web standard APIs only.
- For shared budgets: Redis 6.2 or later, or Valkey 7.2 or later.
- For shared budgets: a connected
ioredisornode-redisclient (v4 or v5).
valve has no runtime or peer dependencies. It never imports a Redis client; it uses the one you pass in.
Install the package
Beta until 1.0. APIs may change between releases. Published versions use plain version numbers and install through npm’s default channel. See the release history for published versions and release notes.
pnpm add valvejsEntry points
| Import | Contains |
|---|---|
valvejs | createValve, memoryStore, ValveError, isValveError, defaultFeedback, and the public types. |
valvejs/redis | redisStore and the structural client and adapter types. |
valvejs/headers | Feedback readers: retryAfter, ietfRateLimit, xRateLimit, combine, defaultFeedback. |
Each entry point ships as ESM and CommonJS with TypeScript declarations.
// ESM
import { createValve } from 'valvejs';
// CommonJS
const { createValve } = require('valvejs');Connect a Redis client
You only need Redis when more than one process shares a budget. Create and connect the client yourself. valve never opens or closes it.
import { Redis } from 'ioredis';
import { redisStore } from 'valvejs/redis';
const redis = new Redis(process.env.REDIS_URL!);
const store = redisStore({ client: redis });An ioredis Cluster instance also works. For any other client, pass an
adapter.
Next steps
- Quickstart: queue your first calls.
- Share a quota across workers: configure Redis for several processes.