Dexecure performance engineering blog

Native HTTP/2 support in Node frameworks - Hapi, Koa, Express and more

Inian Parameshwaran
Inian Parameshwaran Nov 5, 2017
3 minutes read

Node recently launched native support for HTTP/2 in their core. In a previous post, we covered why this is an important step and how you can start building basic servers using HTTP/2 already.

However, a lot of developers use MVC or full-stack Node frameworks such as Hapi and Express. Thus, support of HTTP/2 by popular Node frameworks is crucial to ensure adoption. We are monitoring the status of support as most frameworks are actively working on it.

In this post, we will track the HTTP/2 support status in some of the most popular Node frameworks and provide examples of how to implement basic HTTP/2 server where possible. We will keep updating it, and feel free to comment below to let us know if we missed your favorite framework!

Summary

For HTTP/2 to work, you would need HTTPS enabled. If you do not have already, you can generate a free Let’s Encrypt certificate or a self-signed certificate for your own local server to get started.

Hapi

We are glad to find out that Hapi (from v16.6.2) supports HTTP/2 natively.

You can install Hapi with the following command:

npm install hapi

Building a HTTP/2 server with Hapi is pretty straightforward:

Koa

Koa (at least from v2.3.0 onwards) supports HTTP/2 out of the box too.

Start with installing Koa:

npm install koa

We then setup a simple server over HTTP/2:

Express

Express doesn’t support HTTP/2 yet, but the developers are actively working on it. We will update the post once we find a working solution for setting up a HTTP/2 server using Express.

We are following this issue to stay up to date when Express launches HTTP/2 support.

Note that Express does seem to work with the SPDY module. However, SPDY is now dead. You can get it to work with the external HTTP/2 module with some hacks, but we have not found a way to make the HTTP/2 from Node core work with Express yet.

Meteor

HTTP/2 is the second-most requested Meteor feature! We are closely following the progress and will update this post.

Sails

Since Sails is dependent on Express, we expect HTTP/2 support of Sails will follow soon after that of Express. You can follow the progress on their roadmap here and discussion on their Github issue here.

Conclusion

Did you find any other Node framework supporting HTTP/2 now? Let us know in the comments below!

It is undoubtedly important for the front-end community to go performance-first. We are tracking how latest web technologies are adopted in the most popular development tools. Subscribe to our performance engineering blog to stay updated.

Stay updated, because #perfmatters!

Start using a performance-first content delivery network now

First 14 days are free. No credit card is required. Cancel anytime.