Skip to main content
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

CacheModule

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.

ScheduleModule

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.

QueuesModule

In-process baseline queue (Bull-style API). Enable the queues feature, declare processors with #[queue_processor("NAME")], and enqueue jobs via QueuesService.

I18nModule

Locale-aware responses. Call NestApplication::use_i18n() to activate locale detection from query string or Accept-Language, then translate via catalogs in I18nService.

SqlxDatabaseModule

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.

nestrs-prisma

Prisma-style schema-driven access. Ships PrismaModule, PrismaService, and the prisma_model! macro for declarative repositories — no separate codegen step required.

MongoModule

Official mongodb driver integration. Bootstrap with MongoModule::for_root(uri) and inject MongoService to get typed collections and a ping helper.

nestrs-openapi

OpenAPI 3.1 JSON document and Swagger UI. Auto-discovers routes from the RouteRegistry. Customize with #[openapi(summary, tag, responses)] and OpenApiOptions.

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.
FeatureEnables
cacheCacheModule, CacheService, CacheOptions::in_memory()
cache-redisRedis backend for CacheModule (requires cache)
scheduleScheduleModule, ScheduleRuntime, #[cron], #[interval]
queuesQueuesModule, QueuesService, #[queue_processor]
database-sqlxSqlxDatabaseModule, SqlxDatabaseService
mongoMongoModule, MongoService
openapienable_openapi() / enable_openapi_with_options() on NestApplication
graphqlenable_graphql() on NestApplication (async-graphql backed)
microservicesTCP and gRPC microservice transports
mvcServer-side template rendering
filesFile upload / static file serving helpers
http-clientHTTP client utilities
nestrs-prisma is a separate crate, not a feature flag on nestrs. Add it as its own dependency with one of sqlx-postgres, sqlx-mysql, or sqlx-sqlite.

How to enable a module

All optional modules follow the same pattern: enable the Cargo feature, then import the DynamicModule result in #[module(imports = [...])].
# Cargo.toml
[dependencies]
nestrs = { version = "0.3.8", features = ["cache", "schedule"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
use nestrs::prelude::*;

#[module(
    imports = [
        CacheModule::register(CacheOptions::in_memory()),
        ScheduleModule::for_root(),
    ],
    providers = [AppService],
    controllers = [AppController],
)]
struct AppModule;
Run nestrs 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.