Nest 5: The official release 🚀 Node.js in 2018

Today I am excited to announce the official release of Nest 5: A progressive Node.js framework for building efficient and scalable server-side applications.

After a long road, the new major release is finally here and brings tons of improvements, new features, and several bug fixes. However, before diving into new things that have been shipped by this release, I would like to share my individual thoughts with you.

Introduction

When the front-end world announced further innovative ideas, we left a few steps behind, sitting and enjoying that we can create an HTTP server using two lines of code. Even though Node.js by itself thrives very well, an existing tooling set gets stuck in terms of modernity. Whilst performant, less overhead libraries are excellent, a layer on top of them would help a lot in order to create highly extensible products.

Nest was born out of a straight idea: to make the Node.js platform friendly for demanding and reliable systems. To stay simple, but become a fully-featured framework at once. This objective has been the guiding principle for me to this day. Now we have almost 6000 stars ⚡️ on GitHub and we are continuing to grow. A huge thank you to the community and everyone involved!


What’s new?

There is a lot of new things that came up with Nest 5. I can’t list all of them, it would take forever. Nevertheless, I’ll a share a couple of changes that makes me excited about this release. You could find them all in the official documentation.

Performance

We place great emphasis on performance and portability. That’s why Nest 5 is loosely coupled from the underlying web library. Obviously, express is still being used as a default provider, but you’re able to adapt any other package once you fulfil an interface. This capability helps us to achieve a significant performance boosts by creating a built-in fastify adapter.

The fastify adapter is even ~70% faster than express one (read more).

With FastifyAdapter the number of processed requests per second is on average ~70% higher than with ExpressAdapter. In addition, we are able to ship more integrations in the near future with other HTTP libraries, for example, with the polka server.

Extremely fast rebuilds

The blazing fast server-side development helps you quickly and easily experiment with your code.

~1 second to reload your app (read more).

Thanks to the webpack hot reload feature, your application will apply changes even within 1–2 seconds, reducing amount of time spent on the compilation to an absolute minimum.

New documentation

The previous version of the documentation was very poor in terms of valuable content. A bunch of parts has been missed, examples were small and inconsistent.

Together with Nest 5 release, you’ll find more detailed code snippets, in-depth explanations, and clearer design. Visit the documentation today and let us know what you think.

Angular-style consistency

We aren’t a framework for Angular people. Nest syntax is heavily inspired by the Angular design though because it’s well crafted and ideally suited to scalable systems. Besides, Nest should be easy to absorb for people who also come from other languages and various platforms.

But still, the Angular background is definitely a huge advantage. The same concepts and similar design patterns make the learning curve incredibly short. Additionally, in order to reduce inconsistencies, in Nest 5 a few decorators have been replaced by @Injectable() (read more). Furthermore, the module definition has been adjusted as well.

The module definition is almost the same as in Angular.

Another big advantage is an ability to set up global filters, interceptors, pipes, and guards directly inside the module providers, using custom providers feature.

The global interceptor registered inside the module definition.

CLI

The Nest CLI makes it easy to scaffold an application that already works, right out of the box, and improves your developer productivity due to generate command. This tool takes advantage of the powerful angular schematics, giving you full extensibility and reusability.

The CLI overview (new project generation process).

Besides, the generate command will automatically update your code, for example, put newly created service into providers array of the specified module.

The generate command automatically updates your code.

Less opinionated

Previously, the dependency injection has been disabled for both filters and pipes. On the other hand, it was impossible to manually instantiate interceptors and guards. In the new version, either approach is always fine. You decide which method to follow depending on the functionality requirements. When you want your AuthGuard to stay loosely coupled from any module, create an instance immediately.

Otherwise, pass a class and Nest will handle the instantiation responsibility for you.

Moreover, changes didn’t omit guards, interceptors, and filters. The API has changed in order to make them even more flexible and cohesive. For example, in Nest 4 you were able to solely access request argument inside the guard’s canActivate() method. Now you might pick up any argument effortlessly, using eitherExecutionContext or ArgumentsHost (depending on the evaluation context).

Robust microservices

The @nestjs/microservices package has been completely rewritten. It brings a couple of new transporters (for example gRPC) and several improvements to the existing ones, giving you a strong platform to create a different kinds of microservices on top of Node.js. Also, for these services that don’t fit a request-response paradigm, you might make use of the execution context feature.

An example of the gRPC microservice.

Migration from Nest 4

In order to migrate your existing project, follow the guidelines that are available here. Besides, make sure to get rid of all deprecation messages that may appear in your console.


Learn more

During the incoming AngularCamp 2018, I’ll lead a workshop about Nest. If you are nearby, join me to discuss and share your experience with this tool. It would be a pleasure to me!

“Scalable Node.js with Nest” workshop at AngularCamp 2018

Support

Nest is an MIT-licensed open source project with its ongoing development made possible thanks to the support by the community and our principal sponsor — Valor Software 🙏 This framework is a result of the long way, full of sleepless nights, working after hours, and busy weekends. And I fully rely on the goodness ❤️ of the people. If you want to join them, you can read more here.

What’s next?

There is still room for a bunch of improvements in the whole ecosystem.

That’s why I have already started writing down plans for the next major release! Those notes include:

  • Substantially improved GraphQL support
  • Angular Universal SSR integration
  • Enhance quality of 3rd-party packages (swagger, passport, and so on)
  • Markdown support for the documentation
  • Real-world examples, tutorials, articles, and videos
  • AngularCamp 2018 (join the Nest workshop 👈)

Thank you

To all backers, sponsors, contributors, and community, thank you once again! This product is for you. And this is only the beginning of the long 🚀 story.

Like what you read? Give Kamil Mysliwiec a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.