Skip to main content
nestrs is a Rust web framework that lets you build structured APIs using the same architectural patterns as NestJS — modules, controllers, providers, and dependency injection — while running on Axum and Tower. If your team already knows NestJS, nestrs gives you the same mental model with Rust’s performance and safety guarantees.

Why nestrs exists

Large Rust web applications tend to grow into ad-hoc routing files and scattered shared state. nestrs gives you a principled way to organize that code: every feature lives in a module, handlers live in controllers, and shared logic lives in injectable providers. The framework handles wiring them together so you focus on business logic.

Get started in minutes

Scaffold a new project with the CLI and hit your first endpoint in under 5 minutes.

Add nestrs to existing projects

Add the crate and configure Cargo feature flags for the capabilities you need.

Migrate from NestJS

Side-by-side mapping of NestJS decorators to nestrs macros and patterns.

Explore the ecosystem

GraphQL, OpenAPI, WebSockets, microservices, caching, scheduling, and more.

The module / controller / provider model

nestrs organises your application into three building blocks that map directly onto NestJS concepts.
NestJSnestrsPurpose
@Module()#[module(...)]Groups controllers and providers into a feature slice
@Controller() / @Get()#[controller(...)] + #[routes] implDefines HTTP route handlers
@Injectable() provider#[injectable] on a structShared service injected into handlers via Axum State
NestFactory.create()NestFactory::create::<AppModule>()Bootstraps the application
A minimal application wires these together in a few dozen lines of Rust:
use nestrs::prelude::*;
use std::sync::Arc;

#[injectable]
struct Greeter;

impl Greeter {
    fn hello(&self) -> &'static str {
        "Hello, nestrs!"
    }
}

#[controller(prefix = "/")]
#[routes(state = Greeter)]
impl HelloController {
    #[get("/")]
    async fn hello(State(g): State<Arc<Greeter>>) -> &'static str {
        g.hello()
    }
}

#[module(controllers = [HelloController], providers = [Greeter])]
struct AppModule;

#[tokio::main]
async fn main() {
    NestFactory::create::<AppModule>().listen_graceful(3000).await;
}
nestrs assumes comfort with Rust ownership, async/await, and Cargo. It does not replicate NestJS’s TypeScript-first teaching path — it maps NestJS patterns onto idiomatic Rust.

Key features

Dependency injection

Register providers once in a module; nestrs resolves and injects them automatically into your handlers.

Route macros

#[get], #[post], #[put], #[delete], and #[patch] decorators on handler functions inside a #[routes] impl block.

DTO validation

#[dto] + #[IsEmail], #[Length], and other validation macros powered by the validator crate.

Middleware pipeline

Tower middleware layers — CORS, rate limiting, request IDs, tracing, and compression — applied through the NestApplication builder.

API versioning

#[version(...)] on a controller and #[ver(...)] on individual routes for URI-segment versioning.

Microservices

Transport adapters for NATS, Redis, Kafka, MQTT, RabbitMQ, and gRPC through the microservices feature family.

Observability

Built-in Prometheus metrics endpoint, request tracing, and OpenTelemetry export via the otel feature.

CLI scaffolding

nestrs new and nestrs generate create projects and resource skeletons in seconds.

Ecosystem crates

nestrs is a thin façade over a set of focused crates. You can depend on them individually or pull them in through feature flags on the main nestrs crate.
CrateRole
nestrs-coreDI container, module traits, route registry
nestrs-macros#[module], #[controller], #[get], and all other proc-macros
nestrs-eventsIn-process event bus
nestrs-cqrsCommand and query buses
nestrs-wsWebSocket gateway helpers
nestrs-graphqlasync-graphql router integration
nestrs-openapiOpenAPI spec generation and Swagger UI
nestrs-microservicesTransport adapters: NATS, Redis, Kafka, MQTT, RabbitMQ, gRPC
nestrs-prismaPrisma-oriented database module
nestrs-scaffoldCLI — install with cargo install nestrs-scaffold, binary name nestrs
You rarely need to add these crates directly. Enable the corresponding feature flag on nestrs in your Cargo.toml and the framework activates the right integration. See Installation for the full feature flag reference.