redis /node-redis
Redis Node.js client
★ 17,595⑂ 1,997👁 279⑃ 1,527● 2,028▤ 165
More from this author
+0
Daily
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
#302Add support for Sentinel and RE Discovery Service63 comments · 2012-10-10#2975`RedisClientType` type is slow to typecheck (TS performance issue)30 comments · 2025-05-27#1782Redis create cluster issue26 comments · 2021-12-14#1202Error, which is returned from retry_strategy remains uncaught23 comments · 2017-02-27#2416createClient trying to connect with localhost even though URL is for docker's redis instance21 comments · 2023-02-18#1198retry_strategy doesn't reset after flushing the error21 comments · 2017-02-18#1420Creating redis client using options object without host and port.18 comments · 2019-03-16#1765Migration Guide and Breaking Changes is not full enough14 comments · 2021-12-06
Discussions
#3289How to best structure your project node redis for testing? Use testcontainers or mock? Which mock libraries do you recommend?2 comments · 2026-05-22#3224Feedback Request: Type Mapping in node-redis0 comments · 2026-04-09#3204Master in computer science1 comments · 2026-03-24#3203Npm bs npx1 comments · 2026-03-24#3135How are errors actually supposed to be handled?1 comments · 2025-11-12#3027redis cluster connection not happening1 comments · 2025-07-22#2995eslint is crashing with oom when upgrading to v51 comments · 2025-06-10#2960When to use `createClientPool` vs `createClient`?0 comments · 2025-05-09
Latest release
[email protected] [email protected] 2026-08-11What'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