🗄️
Database4M+/wkMIT

redis

redis (node-redis) is the official Redis client for Node.js, providing a full-featured interface to Redis with support for all Redis commands, data structures,

Installation

npm
npm install redis
yarn
yarn add redis
pnpm
pnpm add redis

Import

ESM
import { createClient } from 'redis';

Quick Example

usage
import { createClient } from 'redis';

const client = createClient({ url: 'redis://localhost:6379' });
await client.connect();

await client.set('user:1', JSON.stringify({ name: 'Alice' }));
const user = JSON.parse(await client.get('user:1'));
console.log(user);

About redis

redis (node-redis) is the official Redis client for Node.js, providing a full-featured interface to Redis with support for all Redis commands, data structures, pub/sub messaging, Lua scripting, transactions, and clustering. The v4 rewrite provides a modern async/await API, automatic pipelining for batching multiple commands into a single network round-trip, built-in TypeScript types, and support for Redis modules like RediSearch, RedisJSON, and RedisTimeSeries. The client handles connection management, automatic reconnection, and supports both standalone and cluster Redis deployments. Redis commands are exposed as methods on the client object: client.set('key', 'value'), client.get('key'), client.hSet('hash', 'field', 'value'). The pub/sub API supports subscribing to channels and patterns for real-time messaging between application instances. The client supports Redis Streams for event sourcing patterns, Sorted Sets for leaderboards and priority queues, and HyperLogLog for cardinality estimation. The library works with Redis Sentinel for high availability and Redis Cluster for horizontal scaling. node-redis is the recommended client for Redis in the Node.js ecosystem, particularly for applications using Redis modules.

Quick Facts

Packageredis
CategoryDatabase
Weekly Downloads4M+
LicenseMIT
Installnpm install redis

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.