redis /node-redis

Redis Node.js client

★ 17,595⑂ 1,997👁 279⑃ 1,527● 2,028▤ 165
TypeScriptMITCreated 2010-09-14redis.js.org/
+0
日增长
17,595
stars
1,997
forks
279
watchers
1,527
prs
2,028
issues
165
releases

README

Node-Redis










node-redis is a modern, high performance Redis client for Node.js.

 How do I Redis?

Learn for free at Redis University

Build faster with the Redis Launchpad

Try the Redis Cloud

Dive in developer tutorials

Join the Redis community

Work at Redis

 Installation

Start a redis via docker:

bash
docker run -p 6379:6379 -d redis:8.0-rc1


To install node-redis, simply:

bash
npm install redis

 "redis" is the "whole in one" package that includes all the other packages. If you only need a subset of the commands,
 you can install the individual packages. See the list below.

 Packages

| Name                                           | Description                                                                                 |
| ---------------------------------------------- | ------------------------------------------------------------------------------------------- |
| redis                    | The client with all the "redis-stack" modules |
| @redis/client           | The base clients (i.e RedisClient, RedisCluster, etc.)                                  |
| @redis/bloom             | Redis Bloom commands                     |
| @redis/json               | Redis JSON commands                               |
| @redis/search           | RediSearch commands                     |
| @redis/time-series | Redis Time-Series commands                  |
| @redis/entraid         | Secure token-based authentication for Redis clients using Microsoft Entra ID                |

 Looking for a high-level library to handle object mapping?
 See redis-om-node!


 Usage

 Basic Example

typescript
import { createClient } from "redis";

const client = await createClient()
  .on("error", (err) = console.log("Redis Client Error", err))
  .connect();

await client.set("key", "value");
const value = await client.get("key");
console.log(value); // 'value'
client.destroy();


The same example in CommonJS (for example node example.js without "type": "module" in package.json):

js
const { createClient } = require("redis");

async function main() {
  const client = await createClient()
    .on("error", (err) = console.log("Redis Client Error", err))
    .connect();

  await client.set("key", "value");
  const value = await client.get("key");
  console.log(value); // 'value'
  client.destroy();
}

main().catch(console.error);


The above code connects to localhost on port 6379. To connect to a different host or port, use a connection string in
the format redis[s]://[[username][:password]@][host][:port][/db-number]:

typescript
createClient({
  url: "redis://alice:[email protected]:6380",
});


You can also use discrete parameters, UNIX sockets, and even TLS to connect. Details can be found in
the client configuration guide.

To check if the client is connected and ready to send commands, use client.isReady which returns a boolean.
client.isOpen is also available. This returns true when the client's underlying socket is open, and false when 

Top issues

Discussions

Latest release

[email protected] [email protected] 2026-08-11
What's Changed
 fix(sentinel): cap post-connect rediscovery retries by @DebadityaHait in https://github.com/redis/node-redis/pull/3388
 chore(deps): bump ip-address and socks by @dependabot[bot] in https://github.com/redis/node-redis/pull/3389
 feat(client): add MaxCommandRedirectionsError for cluster redirections by @Piyush0049 in https://github.com/redis/node-redis/pull/3386
 fix: remove stale data listener explicitly on socket error by @Chrisp1tv in https://github.com/redis/node-redis/pull/3209
 fix(client): dispose credentials subscription on every close() path by @lazerg in https://g

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON