Why choose Nest.js as your backend framework?

Grzegorz Laszczak
selleo
Published in
5 min readNov 1, 2020

NestJS is a framework for building efficient and scalable NodeJS server-side applications built with and fully supporting TypeScript. It uses robust HTTP Server frameworks like Express or Fastify. Nest provides a level of abstraction above the common NodeJS frameworks and exposes their APIs to the developer. This gives a great amount of freedom to use third-party modules.

A good reason to choose NestJS over ExpressJS (one of the most popular NodeJS frameworks) is the fact that when a new project in NodeJS is started it is a clear architecture based on a few simple components (controllers, modules and providers). This gives great ease to split applications into microservices.

Are you wondering why choose NestJS as your backend framework? Keep reading.

What is NestJS?

As mentioned, NestJS is an open-source, extensible, versatile, progressive NodeJS framework for creating compelling and demanding backend systems. It is currently the fastest-growing NodeJS framework in TypeScript.

NestJS is used for writing scalable, testable and loosely coupled applications. It brings scalable NodeJS servers to a whole new level. It supports databases like PostgreSQL, MongoDB, MySQL. NestJS is heavily influenced by Angular, React and Vue and offers dependency injection right out of the box.

As of January 2020, it has over 23k GitHub stars and its weekly npm download rate is almost 180k. It encourages developers to try, learn and use some well-known software development paradigms and its documentation has lots of examples, recipes and code sources.

NestJS is easily extendible, as it can be used with other libraries; versatile thanks to its adaptive fully-fledged ecosystem and progressive, bringing JavaScript features and design patterns.

Building blocks of NestJS

Modules: used to organize the code and split features into logical reusable units. Grouped TypeScript files are decorated with “@Module” decorator which provides metadata that Nest makes use of to organize the application structure.

Providers: also called services, which are designed to abstract any form of complexity and logic. Providers can be created and injected into controllers or other providers.

Controllers: responsible for handling incoming requests and returning appropriate responses to the client-side of the application (for example call to the API).

Incredible features of NestJS

Recently, the NestJS framework has been gaining extreme popularity due to its incredible features. Some of them are:

  • It leverages TypeScript — strongly typed language which is a superset of JavaScript
  • Easy to use, learn and master
  • Powerful Command Line Interface (CLI) to boost productivity and ease of development
  • Detailed and well-maintained documentation
  • Active codebase development and maintenance
  • It is open-source (MIT license)
  • Support for dozens of nest-specific modules that help you easily integrate with common technologies and concepts like TypeORM, Mongoose, GraphQL, Logging, Validation, Caching, WebSockets and much more
  • Easy unit-testing applications
  • Created for Monoliths and Micro-services (an entire section in the documentation regarding Microservice types of NestJS applications as well as techniques and recipes)

Why choose NestJS

Java as a programming language is more than 20 years old. For many years, it was the main framework for creating business applications, but recently, the focus shifted towards NodeJS. Because of its speed NodeJS took the developer world by storm allowing to enjoy all the benefits of JavaScript and writing both frontend and backend in the same programming language. Since NestJS is the fastest growing framework for NodeJS, let’s talk about the reasons why why choose NestJS over your current framework?

  • A quick and efficient development process.
  • Highly scalable and easy to maintain applications.
  • Fastest growing NodeJS framework for the past 3 years.
  • Large community and support system.
  • Nest has positioned itself at a unique crossroad of front end and mid-tier development that many languages have struggled to find.
  • The use of TypeScript helps ensure that Nest will remain relevant in the rapidly changing JavaScript landscape and gives developers less context switching.
  • Great documentation.
  • Easy unit testing.
  • Built for large scale enterprise applications.
  • Nest provides an out of the box application architecture that allows developers and teams to create highly testable, scalable, loosely coupled and easily maintainable applications.
  • With NestJS you can build Rest API’s, MVC applications, microservices, GraphQL applications, Web Sockets or CLI’s and CRON jobs.
  • It uses the best of NodeJS, TypeScript, and bullet-proof architectural patterns.
  • The structure of the application in Nest is heavily based on Angular. The structure is very simple and allows more attention to be paid to the design of endpoints and their consumers, instead of the application structure.
  • NestJS forces developers to use a specific architecture by introducing Angular-like modules, services, and controllers, ensuring the application is scalable, highly testable, and loosely coupled contrary to other NodeJS frameworks like Express or Koa where a mistake early on in the project regarding the architecture may cost a lot in terms of time spent refactoring the codebase later.

Who is using NestJS?

The benefits of using NestJS are widely recognized by some of the biggest companies that are looking to do more in less time. The most popular ones are:

Roche

This multinational healthcare company that operates under two divisions pharmaceuticals and diagnostics and controls the American biotechnology company Genetech is using NestJS on their main website.

Adidas

A designer and manufacturer of shoes, clothing and accessories is the largest sportswear manufacturer in Europe and the second largest in the world. This is probably why they decided to use a highly scalable framework to build large scale efficient applications.

Capgemini

This French multinational corporation providing consulting, technology, professional, and outsourcing services is also using NestJS for their application architecture.

Decathlon

Sporting goods retailer with over 1,500 stores in 57 countries chose NestJS as the backend for their web application.

When discussing the companies who are using NestJS it is also worth mentioning sample open-source projects like:

Summary

NestJS gives developers a great head start. All you need to start the development is to set up a new app and you are ready to go. This framework gives you a huge boost right at the very beginning while helping you take further steps by defining proper app architecture.

NestJS uses modern solutions and technologies, so the applications created with it are maintainable and long-lasting. It can be connected with GraphQL, WebSockets or used for building microservices.

All that makes NestJS an excellent framework, so if you are thinking about upgrading or building a new product this is the way to go. And if you are in need of an experienced team that can get you through the shift or build a NestJS app from scratch, contact Selleo.

--

--