Introducing Feathers 5 — The API and real-time application framework

David Luecke
The Feathers Flightpath
6 min readFeb 28, 2023

--

The Feathers birds in mission control
Feathers 5 mission control — Ready for takeoff

Today we are happy to announce the release of Feathers 5 Dove 🕊️, a framework for creating scalable web APIs and real-time applications. Built with TypeScript, Feathers works with NodeJS and any backend technology and comes with built-in support for instant SQL and MongoDB APIs. It also integrates smoothly with popular frontend technologies like React, VueJS, and Angular in the browser, as well as React Native, and can be used with any other API client.

After almost two years of development and over three dozen prereleases, it is by far the most ambitious release in its decade-long history, bringing together tried and true patterns and best practices with cutting-edge features for modern web development. Going through everything new would make for a very long post, so today, we are just going to highlight some of the most interesting parts. For a longer overview of Feathers and the new release, check out the launch party stream I did earlier this month with coding.garden 🌱 🐦

TypeScript all the way

Feathers has been a TypeScript-friendly framework for a few years, but TypeScript support took a huge leap forward with Feathers Dove. We’ve completely rewritten all of Feathers in TypeScript. And we’re not talking about a lightweight TypeScript implementation. It’s TypeScript all the way down. Everything from the official database adapters right down to Feathers core and the new CLI. You can still choose JavaScript to create an application and see examples in the documentation, but it all comes from a single TypeScript codebase.

Professor bird thinks that types are more verbose but will make life easier in the long run
Professor bird thinks that types are more verbose but will make life easier in the long run

What we are most excited about is something that has only more recently become possible thanks to improvements in TypeScript’s type system: Defining the data schema and validations and automatically getting types for it. Feathers schema introduces a database-independent way to define your data model and validations using JSON schema or TypeBox and get the correct and always up-to-date types for it.

Combined with the unique client integration that Feathers has had for many years, we get an end-to-end typed development experience, including the new custom service methods, with any frontend framework like React, Vue, Angular, or React Native.

Typed code completion using Feathers on the client

All of this is done only with TypeScript and a standard HTTP (REST) or Socket.io API. There are no additional compilation steps, no custom RPC protocol, and things don’t get slowed down by parsing a domain-specific language like GraphQL. Since type information gets removed at compile time, there is also no other performance or bundle size overhead.

So is it fast?

We get it. Nobody wants to use a slow framework. So, whether with the typed Feathers client or any other HTTP or WebSocket library, how fast is it? Feathers always worked as a drop-in replacement on top of Express, and now in this version, we also added support for Koa as a more modern and faster alternative. Here are some benchmarks I ran on my M1 Mac:

Requests per second for Feathers 4 at 13524, Express at 18182, Feathers 5 at 38666, Koa at 39997 and Fastify at 50000
Requests per second for 10 concurrent connections

As you can see, Feathers 5 using Koa offers a significant improvement over Express (and anything built on top of Express) and performs very similarly to Koa itself. We do have to tip our beak 🐤 to Fastify for being undoubtedly the fastest Node HTTP framework, which is fair. Our main goal for this release was to offer a faster alternative to Express while keeping Feathers’ “batteries included” (but optional) development experience with built-in features like authentication, client integration, and database support.

However, if performance is important, it might be worth looking beyond plain HTTP. As still one of the only frameworks, Feathers comes with first-class support for WebSockets via Socket.io. You can access the same API entirely through a WebSocket connection, and Feathers-based WebSocket APIs are easier to scale than traditional WebSocket apps thanks to the stateless architecture. When using the Feathers client, you won’t even notice a difference in how it is used. You don’t just get real-time updates for free; in the common case that a client makes multiple requests, there is also a good chance that communication can be quite a bit faster. I did a comparison a few years ago, and now the current benchmark looks like this:

Requests per second for Feathers 4 at 13524, Express at 18182, Feathers 5 at 38666, Koa at 39997, Fastify at 50000 and Feathers 5 with Socket.io at 83289
Requests per second for 10 concurrent connections

We’ll talk more about these numbers (and why microbenchmarks shouldn’t be the only reason for choosing a framework) in a future post, but the point is that if performance is important, Feathers makes it easy to pick the best protocol for the job. Thanks to the transport-agnostic architecture, you can achieve significant performance improvements without having to rewrite everything in a new framework or for a different protocol.

Instant SQL and MongoDB APIs

Feathers can be used to create any API and connect to any database. Writing all the CRUD logic yourself can be pretty cumbersome, though, so there have been pre-built integrations for many different databases and ORMs for quite a while. They are fully customisable, while also providing the standard functionality to create, read, update, and delete data and even make more complex queries out of the box.

Over the years, we have seen quite a few ORMs and even databases come and go. The integrations that have proven to be the most reliable were the low-level database drivers for SQL databases and MongoDB. Combined with the new database-independent schema definitions and resolvers, our database adapters can do a lot of the heavy lifting of a traditional ORM while keeping things faster and more flexible. This is why the SQL (Knex) and MongoDB adapters are now standard database integrations when creating a new application. You get a fully-functional and customisable SQL or MongoDB API (or both), including authentication, by running a few commands with the new CLI.

Prompts of the `npm create feathers@latest my-app` command
Creating an app with the Feathers CLI

Flying onward

Feathers has never been the framework everybody talks about or even knows about. This is probably because Feathers works a little differently and because we didn’t often get a chance to talk much about all the things it can do. Still, over the years, it has gathered a small and friendly community and a great ecosystem. From the fun bird illustrations to the new website to everybody who patiently tested the prerelease, asked questions, and gave feedback on Discord, to our sponsors, we are incredibly grateful to all the contributors who made this release what it is.

Over the next couple of months, we will dive more into the new things and more of what we think Feathers was always good at. If anything in this post looks interesting to you, we invite you to join the flock and try it out.

To get started, visit the Feathers website. To learn the basics without generated code, have a look at the Quick Start guide, and to build a fully functional chat application, check out the Chat Application Guide. For any questions and to get help, join the Discord community or start a discussion on GitHub.

--

--