Node.js server frameworks: hapi.js or express.js?

Which one would you use, when and why?

I know express.js but I came across to hapi.js just recently. I would like to see what other people think.

I like Express but haven’t tried Hapi. We use Express here at FCC and I think it is more popular, for whatever that is worth. I might suggest this article.

1 Like

Express is kinda the simplest possible framework; it’s based on Sinatra, the no-frills Ruby framewok (compare to Ruby on Rails, which gives you almost everything you need out of the box).

Hapi is a bit different, it’s a bit more fully featured (out of necessity, it’s Walmart’s server framework), most of that functionality is modular via officially supported plugins. API very easy to learn as well. Used it for one thing at last work [large, complex API], worked really well.

Hapi is pretty excellent, but the choice you have imo is between level of support. Express is the most widely used Node web server framework by a very long way. Very easy so get support, find help, find plugins etc. Hapi you’ll get a much more fully-featured framework out of the box, but much harder to get help.

1 Like

Thanks to you both for your quick response! The article shared by @kevinSmith is also very helpful.

Help and service is always relevant, as @DanCouper mentions, so I will keep focusing on express.js. However I will try a bit of hapi.js. I had a quick look at hapi.js, it is very much production friendly, focuses on security, and it looks pretty easy to deploy.

Benchmarks I visited suggested that hapi.js was not as fast as express.js but for some cases that shouldn’t be a concern.

People, thanks again!

1 Like

Just purely w/r/t this point, the chances of your app being Walmart-scale are pretty miniscule, and there may be companies of the size of Walmart running pure Express apps, and those apps may be faster, but that’s an irrelevancy.

As a comparison, Twitter used Ruby on Rails. For various reasons, RoR is slow, so Twitter switched to Scala as a backend. But at that point, when the tradeoff between the developer simplicity of RoR and the speed of RoR swung enough toward speed for the switch to be worthwhile, that was when they had hundreds of millions of users.

Don’t pick things because of stupid benchmark games, you don’t have enough users for the benchmarks to matter. If you do have enough users, then you can trivially afford to drop hundreds of thousands of $ on hiring people to optimise stuff for you.

2 Likes