It's been a while since I've last used node to build a backend, and the last time I did Express was the go-to solution. Is that still the case?
I don't have much time to do too much research and I usually default to the most popular solution in such cases.
Maybe it's still standard, but if you don't want to shoot yourself in the foot, just stay away from it.<p>Express's API is horrible. It's not integrated with Promises (async/await) at all, so be prepared to wrap every async endpoint (so probably all of them) with a custom error handling wrapper. If you don't (and don't have a big catch-block around the whole implementation), an unhandled error will hang the connection forever without a response.<p>Also, the API makes it pretty much impossible to write "wrapping" middleware, for example if you want output validation. As soon as an express middleware calls `next`, it's done and there's no way intercepting it before a response is sent.<p>It also <i>still</i> doesn't support Node's HTTP2, just some (nowadays) weird third-party HTTP2 implementation.<p>The standard `compression` middleware also seems abandoned, not supporting brotli (so you'll have worse loading times), despite Node.js natively providing the required functions for years.<p>I'll second `fastifiy` or `koa`.
Not only is expressjs <i>de-facto</i>, it actually is a community design from before Node.js existed, with earlier implementations (connect, jackjs), including on non-Node.js SSJS-platforms; cf. [1]. Moreover, an expressjs/JSGI middleware can plug-in and directly run off the Node.js core http API, without the additional expressjs routing, etc.<p>[1]: <a href="https://wiki.commonjs.org/wiki/JSGI/Level0/A/Draft2" rel="nofollow noreferrer">https://wiki.commonjs.org/wiki/JSGI/Level0/A/Draft2</a>
I used to do more node work, and that was mostly pre v4. Express was the go-to.<p>There’s more options out there now. I did a bit of research a few years back, and my go-to now is Fastify.<p><a href="https://fastify.dev/" rel="nofollow noreferrer">https://fastify.dev/</a>
I love threads like this, it's so stereotypical JS. OP asks if it's the de-facto choice which it objectively is, but everyone recommends their pet project or favourite library instead.
You might want to look at <a href="https://www.meteor.com/" rel="nofollow noreferrer">https://www.meteor.com/</a>. There aren't a lot of alternatives to it that do such a good job of providing its benefits:<p>- Zero-config build tool<p>- Accounts system included<p>- Live reactive data system included<p>- Easy interface to React, Svelte, Vue<p>- Can use its out-of-the box MongoDB integration or integrate with any database via GraphQL<p>- Great community forum<p>A new version 3.0 is almost done.
I did the same research a few months ago. There are a lot of really cool alternatives which is fun and exciting, but at the end of the day I went with express. It's super stable, huge community, endless online tutorials and content.<p>The most tempting alternatives were hono and fastify. Hono felt not mature enough.<p>At the end of the day your server framework is very rarely the bottleneck in your system's performance, so it matters less.
It's still the most popular but for the past couple of years it hasn't seen any major updates and some people question if the project is abandoned.<p>I switched to Fastify and haven't looked back.
Yes it is, Bun is promising but still in early stage. If you're looking for a battle-tested framework I would suggest Nest.js, which supports both Express and Fastify in a virtually transparent way.
I'd definitely suggest at least considering Nest.JS.
There's totally nothing wrong with Express (or Koa or Fastify) projects, but Express based projects tend to share problems with all others based on minimalistic-based frameworks - no skeleton means tons of discussions about favorite ORM, Logger, Validation, whole story about service vs helpers etc.
If I can skip it, I always do. Decision paralysis can be a killer.
It seems like it. There are alternatives like Koa and Fastify, but none of seem to strike quite the balance that express does. I pray that one day express 5 will get released and they’ll finally fix the whole async middleware not handling errors properly thing though. That’s gotta be one of the most annoying quirks that has just been quietly sitting there untouched for years at this point. Maybe one day.<p>I guess there’s Bun and Elysia now too, but that’s pretty bleeding edge by comparison.
If you're sure you want a traditional strictly-serverside backend, Fastify is like an improved Express. But your project's success might depend on going beyond a hasty sanity-check that presupposes app architecture. What's your front-end look like? For React, using a framework like Remix (or Next.js) that spans client and server runtimes, could make Fastify/Express potentially moot.
I'd say adonis is the best now as you can iterate to a full product very quickly.<p>It's full stack but still amazingly fast (comparable to fastify). You can choose what you need in order to improve speed too. The syntax mimics Laravel which is the easiest to use, most complete full stack framework of any language.<p>Obviously, somewhat opinionated claims and my main job isn't programming so take it for what it's worth.
Follow-up question: Is there any backend framework which uses the fetch API. That is, where requests are standard Request objects (<a href="https://developer.mozilla.org/en-US/docs/Web/API/Request" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/Request</a>) and where you send (or return, or yield) standard Response objects (<a href="https://developer.mozilla.org/en-US/docs/Web/API/Response" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/Response</a>)?<p>I’m teaching a highschool kid web development and it would be very nice to be able to teach the same standard on the back end as we use on the front end.
I feel like it's a matter of the beast you know vs working with something new. A lot of packages of been created to work with express so when working with it you get a larger ecosystem available to you. However, I think it's akin to React for frontend where just because it's the standard for node these days doesn't mean it should be
I've been on various projects that utilized Express, Koa, and NestJS (which wraps Express or Fastify).<p>Of the three, I'd choose Koa again over the others. Their design works better with modern javascript (async/await). While there may be fewer middleware packages for Koa than Express, it's usually not that hard to write your own if you can't find what you need.<p>For NestJS I didn't care for the decorator-driven "Spring-like" design. In JS codebases it's more natural to take a functional approach.
Fastify is definitely the new Express for me. I use it in production since many years !<p>Fastify main contributors are Nodejs contributors and help Nodejs language to be better and better.<p>I really never understood how in 2023 Express can still be the de-facto and included in so many beginner’s tutorials…
Nitro is the server baked into nuxt 3. I feel like web server frameworks have all been circling around the same set of features for like 10 years though.
Express is still the "go-to" now, because it's the rare case of a Node library that's stable, battle-tested, and doesn't change much. (Yes, the maintainers having not been able to release v5 has actually been a sort of advantage.)<p>But, there are other great options to go with now, and you probably won't go wrong with fastify or hapi.
<a href="https://www.hackernewsdaily.com" rel="nofollow noreferrer">https://www.hackernewsdaily.com</a> is built on Meteor - haven't touched it for years and its working great<p>really easy to update apps too
I tend to use hapi (<a href="https://hapi.dev" rel="nofollow noreferrer">https://hapi.dev</a>) instead of Express if I need to write a quick backend for something these days.<p>Fastify looks nice too but I haven't used it.<p>Been burnt by full-stack frameworks in the past (e.g. Meteor) but they can be a good option for some.
I just use the native Node APIs and write the tools I need when I need such tools. The really tough problems I would need something like Express to solve for are not solved by something like Express.
All of the responses talk about a framework and I know you're thinking you need one too. But, I'm more curious about your plans to host things.<p>The reason I ask is because there are alternatives, like Google Cloud Functions [0], where you don't need a framework at all. You just write a handler and you're done. Connect it with Github actions for deployment.<p>There are other services out there, but I like GCF cause it'll auto scale. Need a database? Cloud SQL Postgres. Need a queue... Cloud Tasks... etc... so many problems solved in a relatively non-vendor lockin way.<p>EDIT: I'm getting downvoted for trying to make a helpful comment to the OP. Good work HN!<p>[0] <a href="https://cloud.google.com/functions/docs/console-quickstart" rel="nofollow noreferrer">https://cloud.google.com/functions/docs/console-quickstart</a>
Last I checked, Express is extremely slow and will significantly impact your SEO if you're a content business and doesn't really scale very well if you get huge amounts of traffic like I have.<p>These days I use Go, Deno or Crystal which is much faster.<p>For hosting I recommend Cloudflare Pages, Vercel, (maybe Netlify) and Render.