> ## Documentation Index
> Fetch the complete documentation index at: https://nestcrate.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# nestrs ecosystem: optional modules and features

> nestrs optional modules cover caching, scheduling, queues, i18n, and databases. Enable each with a Cargo feature flag and register it like any other module.

nestrs keeps its core lean. Everything beyond the HTTP layer — caching, recurring tasks, queues, i18n, SQL databases, MongoDB, OpenAPI, and more — lives in optional feature flags or companion crates. You opt in explicitly: add the feature to `Cargo.toml`, import the matching module, and wire it into your `#[module]` declaration the same way you would any other provider.

## Available modules

<CardGroup cols={2}>
  <Card title="CacheModule" icon="database" href="/ecosystem/caching">
    In-process key/value cache with optional TTL. Swap the in-memory backend for Redis by enabling
    the `cache-redis` feature. Exposes `CacheService` with `get`, `set`, `del`, and `ttl` operations.
  </Card>

  <Card title="ScheduleModule" icon="clock" href="/ecosystem/scheduling">
    Run cron jobs and interval tasks inside your process. Backed by `tokio-cron-scheduler`. Declare
    tasks with `#[cron("...")]` or `#[interval(ms)]` on a `#[schedule_routes]` impl block.
  </Card>

  <Card title="QueuesModule" icon="list" href="/ecosystem/scheduling">
    In-process baseline queue (Bull-style API) under `queues`. For multi-instance
    production, enable `queues-redis` — durable Redis lists (`LPUSH` / `BRPOP`),
    not the BullMQ wire protocol. Declare processors with `#[queue_processor("NAME")]`.
  </Card>

  <Card title="I18nModule" icon="globe" href="https://docs.rs/nestrs">
    Locale-aware responses. Call `NestApplication::use_i18n()` to activate locale detection from
    query string or `Accept-Language`, then translate via catalogs in `I18nService`.
  </Card>

  <Card title="SqlxDatabaseModule" icon="server" href="/ecosystem/database">
    Direct SQLx access via `AnyPool`. Enables `SqlxDatabaseService` with a shared pool and a
    `ping` helper. Lighter than nestrs-prisma if you only need raw SQL.
  </Card>

  <Card title="nestrs-prisma" icon="table" href="/ecosystem/database">
    Prisma-style schema-driven access. Ships `PrismaModule`, `PrismaService`, and the
    `prisma_model!` macro for declarative repositories — no separate codegen step required.
  </Card>

  <Card title="MongoModule" icon="leaf" href="/ecosystem/database">
    Official `mongodb` driver integration. Bootstrap with `MongoModule::for_root(uri)` and inject
    `MongoService` to get typed collections and a `ping` helper.
  </Card>

  <Card title="nestrs-openapi" icon="book" href="/ecosystem/openapi">
    OpenAPI 3.1 JSON document and Swagger UI. Auto-discovers routes from the `RouteRegistry`.
    Customize with `#[openapi(summary, tag, responses)]` and `OpenApiOptions`.
  </Card>

  <Card title="nestrs-oauth2" icon="lock" href="/guides/oauth2">
    OAuth2 client (authorization code + PKCE, client credentials, refresh) and a JWKS-backed
    resource server (`JwtVerifier`), plus social providers (Google / GitHub / Microsoft /
    Apple) and `OAuth2Guard` route protection. Enable the `oauth2` feature on `nestrs`.
  </Card>

  <Card title="nestrs-storage" icon="hard-drive" href="https://docs.rs/nestrs-storage">
    Multi-cloud object storage behind one `Storage` trait — Local filesystem, S3, GCS, and
    Azure Blob backends — with presigned-URL helpers and the `#[upload_to]` decorator.
  </Card>

  <Card title="Adapter crates" icon="plug" href="/adapters/overview">
    Socket.IO, Lambda, Passport, Better Auth, BullMQ, SAML, LDAP, and SeaORM — companion
    crates for NestJS surfaces that do not fold into Axum.
  </Card>
</CardGroup>

## Feature flag reference

Add features to the `nestrs` dependency in your `Cargo.toml`. Features compose: you can combine any of them in a single project.

| Feature | Enables |
| - | - |
| `cache` | `CacheModule`, `CacheService`, `CacheOptions::in_memory()` |
| `cache-redis` | Redis backend for `CacheModule` (requires `cache`) |
| `schedule` | `ScheduleModule`, `ScheduleRuntime`, `#[cron]`, `#[interval]` |
| `queues` | `QueuesModule`, `QueuesService`, `#[queue_processor]` |
| `queues-redis` | Durable Redis lists (`LPUSH` / `BRPOP`) for `QueuesModule`. Not the BullMQ protocol. |
| `session` | In-memory `tower_sessions` (`use_session_memory`) |
| `session-redis` | Redis-backed sessions (`use_session_redis`) |
| `database-sqlx` | `SqlxDatabaseModule`, `SqlxDatabaseService` |
| `mongo` | `MongoModule`, `MongoService` |
| `openapi` | `enable_openapi()` / `enable_openapi_with_options()` on `NestApplication` |
| `graphql` | `enable_graphql()` on `NestApplication` (`async-graphql` backed) |
| `microservices` | TCP and gRPC microservice transports |
| `mvc` | Server-side template rendering |
| `files` | File upload / static file serving helpers |
| `http-client` | HTTP client utilities (`HttpModule` / `HttpService`) |
| `sse` | Server-Sent Events (`SseResponse`, `serialize_to_event`) |
| `throttler` | Per-route rate limits (`ThrottlerModule`, `ThrottlerGuard`) |
| `oauth2` | OAuth2 client, JWKS-backed resource server, `OAuth2Guard`, and `NestApplication::use_oauth2` via the `nestrs-oauth2` crate (see the [OAuth2 guide](/guides/oauth2)) |

<Note>
  `nestrs-prisma`, `nestrs-storage`, and the [adapter crates](/adapters/overview) (`nestrs-socketio`, `nestrs-lambda`, `nestrs-auth-strategy`, `nestrs-better-auth`, `nestrs-bullmq`, `nestrs-saml`, `nestrs-ldap`, `nestrs-sea-orm`) are separate crates, not feature flags on `nestrs`. Add `nestrs-prisma` with one of `sqlx-postgres`, `sqlx-mysql`, or `sqlx-sqlite`. Add `nestrs-storage` with one of `local`, `s3`, `gcs`, `azure`, or `all`.
</Note>

## How to enable a module

All optional modules follow the same pattern: enable the Cargo feature, then import the `DynamicModule` result in `#[module(imports = [...])]`.

```toml theme={null}
# Cargo.toml
[dependencies]
nestrs = { version = "1.6.0", features = ["cache", "schedule"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
```

```rust theme={null}
use nestrs::prelude::*;

#[module(
    imports = [
        CacheModule::register(CacheOptions::in_memory()),
        ScheduleModule::for_root(),
    ],
    providers = [AppService],
    controllers = [AppController],
)]
struct AppModule;
```

<Tip>
  Run `nestrs-cli doctor` in the CLI to check that your feature flags match what each module expects. Mismatched features usually produce "feature not enabled" link-time errors.
</Tip>
