Skip to content(if available)orjump to list(if available)

Koa – Next generation web framework for Node.js

dsego

Afaik, Koa is old, was supposed to be the next express, but somehow it never gained enough traction. That's my understanding. From a technical standpoint, Koa was all about composing middleware and using JS generators. I don't think that's relevant anymore. If you are interested in something more modern, look at Bun or Deno frameworks like ElysiaJS or Hono.

lolinder

You know, I've pushed back against the idea that the JavaScript ecosystem is absurd in its churn. I've argued that it's largely stabilized. But then I read comments like this, and they almost change my mind.

> Koa is old

9 years since 1.0, so sure, that's "old" by some definition. That said, I've been hoping we can get past that definition now that JS-the-language stopped iterating as quickly.

> but somehow it never gained enough traction. ... look at Bun or Deno frameworks like ElysiaJS or Hono.

Elysia has 45k downloads a week and Hono has 460k, but it's Koa at 2.5m downloads a week that never gained enough traction?

Koa never managed to unseat Express because the average Node developer is sick of framework churn and wants to just build stuff. The even-newer frameworks aren't somehow more likely to do so than Koa was.

> From a technical standpoint, Koa was all about composing middleware and using JS generators. I don't think that's relevant anymore.

Can you elaborate? What's the new, 'relevant' technical foundation for an HTTP server library?

dsego

That was more a response to the "next generation" verbiage used, when it's more of a venerable or established library, so not relevant in the term of hot new thing. Usually when posting a next gen web framework the expectation is that it brings something new, for Koa that was improvements over express, and I feel like that's not next generation anymore, since we've had many changes to the JS ecosystem since then, new runtimes like Bun and Deno, the rise of typescript, promises everywhere, hybrid server/client frameworks, etc.

nine_k

Are generators still relevant as a performance / concurrently tool, in presence of async support? Or what's the point of Koa's alleged heavy use of generators?

lolinder

Async generators are a feature built into the language because generators and async/await solve orthogonal problems.

That said, I also honestly don't know what specifically we're talking about here—I've used Koa on a few small projects and never used a generator for it. I landed on it because it has first-class support for async. Maybe there are generators used under the hood?

I didn't bother questioning the generators in the first post not because I knew what they were referring to but because the main thrust to my question remains either way: what's the new technical foundation that Koa is supposedly lacking, and why must every JS framework use the latest hotness?

Koa supports async and otherwise feels very much like express. That has been plenty good for me.

Edit: Google turns up no references to generators whatsoever on the koajs.com pages, so I'm not at all sure what OP was talking about. But again—I'm less concerned about whether they got the details of the implementation correct than I am about the idea that JS frameworks need to be swapped out constantly to stay relevant.

https://www.google.com/search?q=site%3Akoajs.com+generators

Aspos

Just a few first instalments used generators, yes, but all the subsequent releases do not, ever since await was introduced in JS.

Koa is awesome.

briscoooe

I'm not sure "next generation framework" and "requires Node v12 for ES2015 and async function support" belong on the same landing page

dsego

Old and abandoned (?), I don't think the poster realized this is not a new new framework. I mean, it was new years ago, before JS async was a thing even.

Here is a post from 2013 explaining how Koa eliminates callbacks with yields.

https://blog.stevensanderson.com/2013/12/21/experiments-with...

edweis

It is still maintained (last commit 2 months ago) and yields are deprecated in favor of promises now.

They am even removing generators in v3

kylecazar

Yeah, to be fair while this link was submitted now, the project's site is from like 2014.

edweis

We are using Koa in production, and the library is still being maintained.

IMH, the upside is that it's a light abstraction of the node's HTTP request. All extensions are provided in different packages (unlike express).

The downside is that you need to set up the basics (like routers[0]) that are out-of-the-box.

[0] https://www.npmjs.com/package/koa-router

fbn79

Same like you. I like it because is less a framework, and more like a library. Light alternative compared to Express. You can use it as base and choose the library you prefer for other functionality (routing,body-parsing,... )

quibono

If you were to start over would you still go for Koa, or something else instead?

edweis

I did start several small projects and always used koa without reconsidering it.

gnabgib

Submitted first in 2013 (281 points, 121 comments) https://news.ycombinator.com/item?id=6933358

quibono

How mature is the ecosystem built around this? Is this a production-ready framework or more of a beta/WIP thing?

pjmlp

Personally unless it is required by customers, it is going to be either Angular or a React metaframework, preferably Spring/ASP.NET if I can do with as little JS as possible.

So every new "next generation" that pops up really needs to be an incredible next generation to matter.

edweis

Koa is a backend API library and is independent of your SPA front end tech.

pjmlp

Doesn't change anything from what I pointed out.

error404x

I used Koa a few years ago. It's good, but meh it’s not really the 'Next generation web framework for Node.js.' I still use Express and sometimes Fastify these days.

aaronrobinson

I inherited a Strapi application and discovered it was built upon Koa and was equally surprised and hopeful I wouldn’t be exposed to it.