Skip to main content
nestrs is available on crates.io. Add it to your project by editing 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. Run rustup 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 the macros and rt-multi-thread features on tokio alongside nestrs:
Your 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 a default = [] feature set — nothing optional is enabled unless you ask for it. Enable features by adding them to the features list on the nestrs dependency:
The table below lists every available feature flag and what it adds to your project.

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-generated Cargo.toml includes a tuned release profile. Add this to your own Cargo.toml for optimised production builds:
panic = "abort" skips stack unwinding on panic. This reduces binary size and can improve performance, but means destructors do not run on panic. Evaluate this setting against your application’s requirements before enabling it.

Environment variables

nestrs reads a .env file at startup via dotenvy. Create a .env file in your project root to configure the runtime:
Set 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.