Nestjs. Is it worth it?

If you've worked with Angular even for a little bit you will find a folder structure very familiar

Blue-eyed cat portrait
Photo by Pacto Visual / Unsplash

TLDR:

Pros

  • The folder structure in Nest is heavily based on Angular
  • If you're a fan of strongly typed languages you will appreciate its built with Typescript
  • It's fast
  • Annotation-driven

Cons

  • Debugging is sometimes pain. ( Mostly because of TypeORM )
  • Deployment causes some downtime so you need to account for that
  • Lack of documentation. Edit: Not valid point anymore. Documentation improved tremendously when I've started working with Nest.

If you've worked with Angular even for a little bit you will find a folder structure very familiar. You can split your projects features into modules and keep them separate that way. Also you get everything what comes with modules. Import/export problems too!

Nest is built with Typescript. I love how it sort of reminds me of swift.

Nest is very fast. You would be surprised by performance if you're coming from something like PHP or Python.

Nest heavily uses Typescript decorator annocations. Controllers, routes, modules, data transfer objects, params, query params and even swagger documentation is annotation based.

While working nest one of main cons is the debugging. It integrates with other frameworks (express/fastify) and npm packages (class-validator, TypeORM). Thats all nice and I respect that maintainers and contributors to the Nest do their best to leverage whats available and avoiding reinventing the wheel. Though sometimes there is an error and you get either nothing in the console or empty object `{}`. Good news is that it doesn't happen too often.  

Edit: I've moved away from TypeORM to a MongoDB. And I don't have any issues with it. If you need SQL you can look into Prisma

Because node is a server it needs to parse and load javascript into memory before it can execute it, so on file change ( deployment ) you must restart it to changes appear.  If you have a mission critical application in mind maybe you should consider a loadbalancer or use a docker. Cloud based solutions such as Google cloud App engine also can be an option!

Edit: I wouldn't mess with App engine in 2022. Cloud Run or Cloud functions are the way to go depending on your use case.  

Nest's documentation isn't the worst, but it can there is a room for improvement and I hope it will get better. You probably will have a question while working and might have a to dig a little deeper in stackoverflow to find answer or advice to point in the right direction.

Edit: Documentation improved a lot and community has grown. Finding anwers to problems is much easier in 2022.

All in all I love how NestJs is growing. Since end of 2018 ( ~20k weekly downloads )  till 2019 June ( ~65k weekly downloads) it has grown by more 300% according to npmjs.com. I plan to use it where I have a chance, because I really enjoy working with it. Definitely I see it growing more in popularity and surpassing other backend javascript frameworks such as AdonisJs or SailsJs.  So give it a spin and try it out for yourself. There is a little bit of learning curve, but I'm sure it's nothing too much.

Edit: In 2022 03 Nestjs weekly downloads has crossed 1 300 000 weekly downloads. Amazing growth.

Cheers!

Karolis