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
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 activate production error sanitisation when you call .enable_production_errors_from_env() in main.
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.