gitmyhub

node-redis

TypeScript ★ 18k updated 6d ago

Redis Node.js client

The official Node.js client library for Redis, lets your server-side JavaScript or TypeScript app send commands to a Redis instance for caching, session storage, job queuing, and pub/sub messaging.

TypeScriptNode.jsRedissetup: moderatecomplexity 2/5

node-redis is the official Node.js client library for Redis. Redis is a fast, in-memory data store that applications use as a cache, a message queue, a session store, or a key-value database. A client library is what your app uses to talk to it; node-redis lets server-side JavaScript or TypeScript send commands to a Redis instance and get results back.

The basic flow is small. You import createClient, connect it (by default to localhost on the standard Redis port, or to any URL you give it including with TLS, a username and password, or a UNIX socket), then call methods that mirror Redis's commands — set, get, hSet, hGetAll. Each Redis command is exposed in two forms: the raw uppercase name and a friendlier camelCase version. Replies come back as JavaScript values (hash reads become objects, list reads become arrays), and Buffers are supported for binary data. Transactions are done by chaining commands after multi() and calling exec(). Pub/Sub messaging, scan-iteration helpers, and connection pooling for blocking commands are also built in. If you need a command the library does not yet wrap, sendCommand lets you call it raw.

You would use node-redis any time a Node.js application needs to talk to Redis — caching expensive results, storing sessions, queueing background jobs, or broadcasting events between services. The package ships as a "whole in one" install that bundles the base client plus extensions for the Redis Stack add-ons: Bloom filters, JSON documents, RediSearch full-text search, Time-Series, and Entra ID authentication. You can also install only the pieces you need.

The library is written in TypeScript. The full README is longer than what was provided.

Where it fits