valve_

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 ioredis or node-redis client (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 valvejs

Entry points

ImportContains
valvejscreateValve, memoryStore, ValveError, isValveError, defaultFeedback, and the public types.
valvejs/redisredisStore and the structural client and adapter types.
valvejs/headersFeedback 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

On this page