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 install redis
yarn add redis
pnpm add redis
Import
import { createClient } from 'redis';Quick Example
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
| Package | redis |
| Category | Database |
| Weekly Downloads | 4M+ |
| License | MIT |
| Install | npm install redis |
Related Packages
ioredis is a robust, performance-focused Redis client for Node.js that supports Redis Cluster, Senti…
Express is the most widely used web application framework for Node.js, providing a minimal and flexi…
Socket.IO is a library that enables low-latency, bidirectional, and event-based communication betwee…
Mongoose is the most popular Object Data Modeling (ODM) library for MongoDB and Node.js, providing a…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.