Node.js web application frameworks
Web application frameworks give us handy tools and resources that allow us to create web apps faster, more efficiently with more automation, and with more support. This is because we don’t have to reinvent the wheel, like we would if we were using pure Node.js. Web application frameworks may be large, incorporating a diverse feature set, or small, concentrated on a highly specialized functionality. They extend the functionality of a given base programming language, and generally enhance the underlying benefits of the language.
Developers can choose to use a particular web application framework, or they may create their own solution, depending on the particular needs of a project or use case.
There are two different type of frameworks:
- Full-stack frameworks
Node.js web microframeworks
Microframeworks are usually used for fast APIs that power complex and highly interactive interfaces, simpler apps or specialized services (i.e. in a service oriented architecture). Most of the time they don’t include templating or persistence libraries and provide only basic components like routing and middleware support to deliver responses.
The most popular Node.js web microframeworks are:
- Express - Express is fairly complete framework - providing basic routing functionality and template rendering. Express leverages the existing Node.js functionality (i.e. callbacks). It’s also the most mature framework from the list with with 7 years of existence.
Koa.js - Koa.js is built by the same team that created Express but it’s much more lower level - it does not include a templating library or routing. This means it needs separate middleware to handle routes (i.e.
koa-routeis required). Koa is more of a library, or a barebone framework, for building apps using middlewares. It started as an attempt to solve common tasks like handling errors, cascading middlewares, asynchronous function with more modern approach like generators, promises, etc.
- hapi - hapi was initially built based on Express but later on developed its own framework (according to the author: “hapi was created around the idea that configuration is better than code, that business logic must be isolated from the transport layer..”). It’s backed by WalmartLabs - just one of many other big companies using Hapi in production. In contrast to Express and Koa, hapi uses plugins to split an application into modules that can be developed independently by distributed teams.
- LoopBack - used mainly for writing enterprise applications and creating REST-based APIs, LoopBack can support a variety of database types and is a very customizable framework gaining traction, backed by IBM labs. LoopBack also comes with a CLI wizard, an API explorer, and other supporting tools that can help to speed-up development.
Node.js Fullstack frameworks
Fullstack Node.js frameworks contain all the bells and whistles to build web applications rendered server side - templating and persistence libraries, components, scaffold generators, etc.
- Sails.js - An MVC framework that look similar to what we know from other languages (Ruby, PHP, Elixir). It contains ORM for communications with the database (with drivers for various database engines), websocket integration, scaffold generators, assets management, etc.
- Meteor - Meteor is more of a platform than just an MVC framework. Meteor integrates the client side app with server side in a single codebase as a whole / integrated application. In contrast to Sails.js, Meteor relies heavily on MongoDB. There are solutions to use different database engines (i.e. PostgreSQL) but they are not as mature as the MongoDB drivers.
- KeyStoneJS - KeyStoneJS is similar to Meteor, in that it is more of a platform, rather than MVC framework, but in this case for building CMS apps. It also relies on MongoDB and does not support other databases at the moment. It automatically creates an admin panel for your management system based on defined domain models, and as an aside, it’s powered by Express under the hood.
All the fullstack frameworks listed above are backed by companies whose business model is based on consulting and supporting the product.
Each framework has its merits
Depending on the business use case you might use a different framework:
- Microservice - Express If you would like to develop or extract from an existing app a specialized part of your app as separate service (e.g. a tax calculator) then Express is solid choice. Usually microservices are doing one thing well, so there is no need for modular architecture nor distributed development.
- API for mobile application - hapi / LoopBack Mobile apps are no longer simple apps; users demand more and more, which requires more functionality on the server side. With hapi, we can start building a modular app from day one; it shows its strengths in larger environments. Being backed by big companies (who also use it for their APIs) means it’s battle tested under high volume environments. For LoopBack, its generators mean we’re able to be productive from the beginning - setup is simple.
- CMS - KeyStoneJS With the KeyStoneJS autogenerated admin panel, it allows developers to focus on implementing business logic and customize the admin parts that require it.
Experts in software development
We are a 100% remote team of software development experts, providing web & mobile application development and DevOps services for international clients.