Releases

nestrs brings NestJS-style modules and controllers to Rust

nestrs aims to import NestJS's module and controller pattern into Rust, using Axum, Tower, and proc macros to tame router wiring as services grow.

Nina Kowalski··2 min read
Published
Listen to this article0:00 min
Share this article:
nestrs brings NestJS-style modules and controllers to Rust
Source: medium.com
This article contains affiliate links, marked with a blue dot. We may earn a small commission at no extra cost to you.

In The Rust Programming Language Forum, Joshyahweh introduced nestrs as a way to bring NestJS’s module, controller, and provider model into Rust without forcing teams to hand-wire every Axum router, piece of state, and middleware layer. The pitch is aimed squarely at the point where a web service stops feeling tidy and starts feeling like a pile of ad hoc composition: once routes multiply, the boundaries between shared state, middleware ordering, and dependency wiring get harder to reason about.

That choice matters because nestrs is not trying to replace the Rust web stack beneath it. It sits on Axum and Tower, two pieces of infrastructure many Rust backend teams already know. Tokio announced Axum on July 30, 2021 as an easy-to-use framework with macro-free routing, declarative request parsing through extractors, predictable error handling, minimal-boilerplate responses, and integration with tower and tower-http. The docs.rs description now frames Axum as an HTTP routing and request-handling library focused on ergonomics and modularity. Tower’s role is just as central: Axum uses tower::Service for middleware, which opens the door to timeouts, tracing, compression, authorization, and reuse across other service stacks.

AI-generated illustration
AI-generated illustration

That foundation gives nestrs a very specific angle. Instead of inventing a new transport layer, it tries to transplant the parts of NestJS that TypeScript teams lean on when a codebase grows: modular structure, dependency injection, and a clearer place to put controllers and providers. NestJS’s own documentation describes it as a progressive Node.js framework built on TypeScript, with modular architecture and dependency injection at its core. In Rust terms, nestrs is betting that some teams want more than a bare router plus shared application state, but still want to stay inside the language’s explicit, composable ecosystem.

Joshyahweh said in a follow-up forum reply that the parts he is most confident in are the core HTTP layer, the DI container, and the proc macros, naming nestrs-core and nestrs-macros. He also pointed to examples/hello-app as the cleanest entry point for seeing how the pieces fit together. Another forum note said the rustdoc pages should link directly to mdBook chapters, a small detail that suggests the project is still sharpening its documentation path as much as its runtime shape.

That leaves nestrs in an interesting spot in the Rust stack: high-level enough to promise less wiring, but still anchored to Axum and Tower’s explicit composition model. The real test is whether it can give Rust web teams the NestJS-style structure they miss without blunting the control that makes Rust appealing in the first place.

This article was produced by Prism’s automated news system from verified source data, official records, and press releases, then run through automated quality and moderation checks before publishing. The system is built and supervised by the people who set the standards it runs under. Read our full AI policy.

Did this article answer your question?

Discussion

More Rust Programming News