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.| NestJS | nestrs | Purpose |
|---|---|---|
@Module() | #[module(...)] | Groups controllers and providers into a feature slice |
@Controller() / @Get() | #[controller(...)] + #[routes] impl | Defines HTTP route handlers |
@Injectable() provider | #[injectable] on a struct | Shared service injected into handlers via Axum State |
NestFactory.create() | NestFactory::create::<AppModule>() | Bootstraps the application |
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 mainnestrs crate.
| Crate | Role |
|---|---|
nestrs-core | DI container, module traits, route registry |
nestrs-macros | #[module], #[controller], #[get], and all other proc-macros |
nestrs-events | In-process event bus |
nestrs-cqrs | Command and query buses |
nestrs-ws | WebSocket gateway helpers |
nestrs-graphql | async-graphql router integration |
nestrs-openapi | OpenAPI spec generation and Swagger UI |
nestrs-microservices | Transport adapters: NATS, Redis, Kafka, MQTT, RabbitMQ, gRPC |
nestrs-prisma | Prisma-oriented database module |
nestrs-scaffold | CLI — install with cargo install nestrs-scaffold, binary name nestrs |