Nest.js version 11.0 was released
Nest.js version 11.0 was released on January 16, 2025, and it introduces several new features, enhancements, and bug fixes.
Key Features and Enhancements
Logger Improvements:
The default
ConsoleLogger
now supports JSON-formatted logs, making it easier to parse and analyze logs in containerized environments. You can enable JSON logging with a simple configuration:typescript
Copy
const app = await NestFactory.create(AppModule, { logger: new ConsoleLogger({ json: true, colors: true }) });
This feature is particularly useful for production environments, as it eliminates the need for third-party tools for JSON formatting2.
Microservices Enhancements:
New methods like
unwrap
,on
, andstatus
have been added to microservice transporters (e.g., NATS, Kafka, Redis). These methods provide:Direct access to the underlying client instance (
unwrap
).Real-time monitoring of client status (
status
observable stream).Event listeners for critical events like disconnections (
on
method)26.
Faster Application Startup:
- The module opaque key generation process has been optimized, improving startup performance for applications with large dynamic modules. Instead of hashing metadata, the framework now uses object references, reducing overhead2.
Support for Express v5 and Fastify v5:
- Nest.js 11 now supports the latest versions of Express and Fastify. However, upgrading to Express v5 may require adjustments due to breaking changes in route path matching. For example, wildcard routes (
*
) must now be named (e.g.,*splat
)26.
- Nest.js 11 now supports the latest versions of Express and Fastify. However, upgrading to Express v5 may require adjustments due to breaking changes in route path matching. For example, wildcard routes (
New Pipes and Decorators:
A new
ParseDatePipe
has been added to simplify working with dates.The
@Inject()
decorator now supports type narrowing for allowed injection tokens6.
IntrinsicException:
- A new
IntrinsicException
has been introduced, allowing developers to throw exceptions that won’t be auto-logged by the framework.
- A new
Improved Dependency Management:
- Microservice options can now be provided directly from the Dependency Injection (DI) container, offering more flexibility in configuration6.
Bug Fixes
Fixed issues with global module middleware execution order.
Corrected the order of module destruction to match the reverse of module initialization.
Addressed bugs in RabbitMQ bindings and auto-generated queues6.
Breaking Changes
Node.js Version Requirement: Nest.js 11 requires Node.js v20 or higher. Support for Node.js v16 and v18 has been dropped6.
Express v5 Route Matching: Wildcard routes must now be named (e.g.,
*splat
), and optional characters (?
) are no longer supported.
Migration Guide
For a smooth transition to Nest.js 11, refer to the official Migration Guide.
Conclusion
Nest.js 11 brings significant improvements in logging, microservices, performance, and compatibility with the latest versions of Express and Fastify. Developers can leverage these new features to build more efficient and scalable applications. For more details, check out the official announcement and the release notes