Skip to content

Latest commit

Β 

History

349 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NestJS Redis Toolkit Logo

πŸš€ NestJS Redis Toolkit

Modern, production-ready Redis integration for NestJS. Unified APIs, type-safe, and built on the official node-redis client.

Build Status License: MIT TypeScript NestJS node-redis


Overview

NestJS Redis Toolkit is a cohesive set of utilities for Redis in NestJS applications. It provides a consistent developer experience across client connections, microservices transport (Redis Streams), throttling storage, health checks, and distributed locking.

  • Future‑proof: built on the actively maintained node-redis client
  • Consistent APIs: NestJS-first patterns and DI integration
  • Production-ready: lifecycle management and clear, minimal APIs

Learn more

Curious about the story behind this toolkit and how it simplifies Redis in NestJS? Read the introduction on Medium:
πŸ‘‰ The Missing Redis Toolkit for NestJS

Packages

Quick Start

Install the packages you need. For a minimal Redis client setup:

npm install @nestjs-redis/client redis

Minimal setup:

// app.module.ts
import { Module } from '@nestjs/common';
import { RedisModule } from '@nestjs-redis/client';

@Module({
  imports: [
    RedisModule.forRoot({
      options: { url: 'redis://localhost:6379' },
    }),
  ],
})
export class AppModule {}
// app.service.ts
import { Injectable } from '@nestjs/common';
import { InjectRedis } from '@nestjs-redis/client';
import type { RedisClientType } from 'redis';

@Injectable()
export class AppService {
  constructor(@InjectRedis() private readonly redis: RedisClientType) {}

  async setValue(key: string, value: string) {
    await this.redis.set(key, value);
  }

  async getValue(key: string) {
    return this.redis.get(key);
  }
}

For health checks, throttling, locks, Socket.IO, or microservices transport, install the corresponding packages and see their READMEs.

Debug Logging

Enable detailed logging across all toolkit packages by setting the REDIS_MODULE_DEBUG environment variable:

REDIS_MODULE_DEBUG=true npm start

This provides comprehensive operational logging:

[RedisModule] [Connection=<empty>]: Creating Redis client...
[RedisModule] [Connection=<empty>]: [Event=connect] Connection initiated to Redis server
[RedisModule] [Connection=<empty>]: [Event=ready] Redis client is ready to accept commands
[RedisModule] [Connection=<empty>]: Redis client connected

Compatibility

Package Node.js NestJS node-redis
@nestjs-redis/client ^20.19.0 or β‰₯22.12.0 9–12 5–6
@nestjs-redis/lock ^20.19.0 or β‰₯22.12.0 9–12 5–6
@nestjs-redis/schedule ^20.19.0 or β‰₯22.12.0 9–12 5–6
@nestjs-redis/throttler-storage ^20.19.0 or β‰₯22.12.0 9–12 5–6
@nestjs-redis/health-indicator ^20.19.0 or β‰₯22.12.0 9–12 5–6
@nestjs-redis/socket.io-adapter ^20.19.0 or β‰₯22.12.0 9–12 5–6
@nestjs-redis/streams-transporter ^20.19.0 or β‰₯22.12.0 9–12 5–6

All packages support NestJS 9.x through 12.x on Node.js ^20.19.0 || >=22.12.0. Version 2 is ESM-only; synchronous CommonJS require() is supported on those Node.js versions.

Why use this toolkit?

  • Unified, NestJS-first Redis experience across multiple use cases (client, microservices transport, throttling, health, locks)
  • Built on the official node-redis client for long-term maintenance and compatibility
  • Clean APIs with strong TypeScript types and DI-friendly patterns
  • Production-ready lifecycle management (connect/disconnect) and clear error surfaces
  • Minimal, consistent package READMEs so teams can onboard fast

Background

Most NestJS Redis libraries were historically built on ioredis. While ioredis remains stable, maintenance is best-effort and the Redis team recommends node-redis for new projects. node-redis is actively maintained, redesigned from the ground up, and supports new and upcoming Redis features (including Redis Stack and Redis 8 capabilities). This toolkit exists to offer first‑class NestJS integrations on top of node-redis rather than ioredis.

Reference: redis/ioredis (GitHub)

Links

Contributing

Contributions are welcome! Please read the contributing guide in the repository and open issues/PRs with clear context and reproduction steps.

License

MIT Β© CSenshi

Releases

Packages

Contributors

Languages