Cargo.toml directly, or use cargo add. This page covers the minimum required setup, the tokio runtime configuration, and the full table of optional feature flags.
Minimum supported Rust version
nestrs requires Rust 1.88 or later. Runrustup update stable to ensure your toolchain is current before adding the dependency.
Adding nestrs to your project
nestrs depends on tokio for its async runtime. You must enable themacros and rt-multi-thread features on tokio alongside nestrs:
main function must be annotated with #[tokio::main]:
If you use DTO validation with
#[dto] and its field-level macros, also add serde and validator:Optional feature flags
nestrs has adefault = [] feature set — nothing optional is enabled unless you ask for it. Enable features by adding them to the features list on the nestrs dependency:
Transport and protocol features
Microservices features
All
microservices-* features automatically enable the base microservices feature. You do not need to list both.Data and storage features
nestrs-storage is a separate crate, not a feature flag on nestrs. It provides object storage (Local filesystem, S3, GCS, Azure Blob) behind one Storage trait. Add it as its own dependency with one of local, s3, gcs, azure, or all.OAuth2 features
nestrs/oauth2 enables the underlying crate’s client, resource-server, and guard features but not social. For the social provider wrappers (Google, GitHub, Microsoft, Apple), depend on nestrs-oauth2 directly with its own feature flags — client, resource-server, social, guard (implies client + resource-server), and all. See the OAuth2 guide for the full walkthrough.HTTP and request handling features
Infrastructure features
Common configuration examples
Release profile recommendations
The CLI-generatedCargo.toml includes a tuned release profile. Add this to your own Cargo.toml for optimised production builds:
Environment variables
nestrs reads a.env file at startup via dotenvy. Create a .env file in your project root to configure the runtime:
NESTRS_ENV=production to switch nestrs into production mode: 5xx JSON bodies are sanitized by default (generic message, errors dropped, stack traces never reach clients) — no builder call needed. .enable_production_errors_from_env() re-reads the environment explicitly and .enable_production_errors() forces sanitization on in any environment.
Next steps
Quickstart
Build and run your first nestrs project from scratch using the CLI.
Core concepts
Learn how modules, controllers, and providers compose into a structured application.