The Question of Framework Choice
If you were to build a backend Node.js application, a server-side Node.js application, or if you had to build one, which framework would you use, if any? Maybe you would use just Node.js without any framework, but most likely you wouldn't, because obviously using a framework or some libraries makes your job simpler. So which one would you use?
Well maybe you would go for AdonisJS, though you would be one of the few developers who would use it unfortunately, even though it is like Laravel for Node.js and we all found out that Laravel is pretty amazing, but for Node.js no one seems to be interested in it. And I don't know why, but that is what it is, if you take a look at the download numbers on npm.
So more likely than not you would probably not use AdonisJS, but maybe you would use Koa or Fastify, because these are more popular Node.js frameworks, right? Well no, you would probably use Express.js, because the download numbers of Express.js blow everything else out of the window.
And the question is why is that?
The Paradox of Express.js's Flaws
Because if you look at it, Express.js is a framework that looks like it's barely maintained, if you want to say it like this. Now it wouldn't be true to say that it's not maintained anymore, there are releases and especially over the last couple of months there has been more activity in the GitHub repository and so on, but of course overall you don't see lots of new commits there, you don't see many new versions being released, if you take a look at the commit and the version history.
And of course Express.js therefore has certain flaws which have existed for years and which still exist. Asynchronous error handling for example simply isn't that great with Express.js, it is unnecessarily complex. And nonetheless here we are, everyone's using it. And the question is why is that the case?
I mean we're stuck on version 4 since ever you could say, there is a version 5 and we had alpha and beta versions, but we had the first alpha a couple of years ago, the beta phase also drags on forever, it really isn't clear when we'll ever see version 5 released, maybe tomorrow but maybe also in two years, it's hard to tell by looking at the past.
The Core Strengths of Express.js
And yet everyone's using it. Why? Why do you think everyone's using it?
In my opinion the answer is relatively simple. Express.js was one of the first frameworks to be released when Node.js was released and became popular. It vastly simplified the process of building powerful Node.js web servers and backend applications because Express.js is really easy to use, it's not complicated, it's really easy to set up a couple of routes, the concept of registering those middleware functions is really simple and straightforward, and you have a huge ecosystem.
And that's something you shouldn't underestimate, you have a huge ecosystem with plenty of packages which you can use to solve all kinds of problems, be it cores, CSRF tokens, authentication, validation of user input, whatever it is, there is a package for it, or to be honest, there are dozens of packages for each problem as it seems.
Stability vs. Modernity
Now I am aware that we have alternatives that are very compatible to Express, so where you could even use middleware that was written for Express with those packages or with those frameworks. So you could theoretically switch away without problems.
And those alternatives, Fastify for example, also then offer other advantages like possibly better performance and some problems that exist with Express.js which don't exist anymore when switching to such an alternative.
And yet no one does it. And I guess the reason for that is also maybe stability. Of course there hasn't been lots of development on Express.js, but of course on the other hand it therefore is super stable. People know what they get. They know that there won't suddenly be any breaking changes out of nowhere. Instead it's super stable. They know what they get.
The Flywheel Effect of Content and Adoption
And of course, and that's also something that shouldn't be underestimated, Express.js simply is the thing you stumble across everywhere on the internet. If you're looking for backend Node.js development solutions or if you're researching something, if you're looking up the answer to some problem, you'll find Express.js everywhere on Stack Overflow, of course on ChatGPT, lots of courses.
It's that flywheel, you could say, where of course everyone is using Express.js or many people are using Express.js, also when creating a course for example, myself included, because they wanna include a framework or library that they know will be used by many people. So therefore of course this kind of is that wheel that just keeps going where people create content for it, therefore people use it, therefore people keep on creating content on it.
And Express.js really found the perfect spot there, of course, as mentioned, probably also because of its timing when it was released and how it worked back then and how it still works today.
Exploring Key Alternatives: Fastify, Koa, and NestJS
Now of course it is worth mentioning that we have alternatives and even though Express.js is super popular, these alternatives like Fastify are also extremely popular. The download numbers of Koa and Fastify are definitely not something to underestimate. These are huge numbers, so of course these are popular alternatives, they just look small compared to Express.js.
And there also is one other alternative if you look at download numbers than Fastify and Koa, and that would be Nest.js. And Nest.js is a framework that has a different take on Node.js back-end development, because Nest.js is really like Angular, the old Angular if you wanna say it like that, for back-end development. It's a lot about classes and decorators and TypeScript and about dependency injection. It really was inspired by Angular and brought people that Angular-like experience to the back-end.
Now I know there will be many people who say, I don't like the Angular-like experience in Angular on the front-end, why would I use it on the back-end? The simple answer is, you wouldn't. It's not your framework, you shouldn't use Nest.js. But of course, there are plenty of people who like Angular, they're just sometimes not as loud as other people on the internet, I guess. But they exist, Angular is getting used a lot, and therefore of course, as the download numbers of Nest.js prove, there are many people, many teams, many developers who like working with Nest.js. So that indeed, if you just look at NPM download numbers, which might not be the perfect metric, but if you take that as a metric, then Nest.js is more popular than, for example, Fastify.
Conclusion: Why Do You Use Your Framework?
So I guess we have Express dominating everything, then we have Nest.js, which makes sense because it is a different way of building back-end applications with Node.js, so you have a great alternative here. Then we have those alternatives to Express, which have kind of similar approaches to some extent, but which solve many problems Express.js have.
But ultimately, as you can see by those numbers, if you're building a back-end application with Node.js, you will very likely also use Express, at least many other developers do. And I'm now really super interested in learning, why do you think that this is the case? Why are you maybe using Express.js? Why are you using it instead of Fastify or instead of Nest.js? Or why are you not using it? I'm super interested in learning about that, so please let me know in the comments.