Skip to content

CSenshi/nestjs-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 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, 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

Packages

Quick Start

Install the kit and the Redis driver:

npm install @nestjs-redis/kit redis

Minimal setup:

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

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

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

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

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

Prefer kit, or install individual packages

For most users, @nestjs-redis/kit is the simplest way to get started. If you only need a single capability, you can install a specific package directly.

npm install @nestjs-redis/client redis
import { RedisModule } from '@nestjs-redis/client';

Compatibility

Package Node.js NestJS Redis
@nestjs-redis/kit 18+ 9+ 5+
@nestjs-redis/client 18+ 9+ 5+
@nestjs-redis/throttler-storage 18+ 9+ 5+
@nestjs-redis/health-indicator 18+ 9+ 5+
@nestjs-redis/lock 18+ 9+ 5+

All packages support NestJS 9.x, 10.x, and 11.x.

Why use this toolkit?

  • Unified, NestJS-first Redis experience across multiple use cases (client, 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