See all articles

Node.js Web Application Frameworks

JavaScript everywhere is gaining traction in the web app community, with JavaScript backends made possible by the use of Node.js. Node.js is most useful in combination with web application frameworks. We’ve picked out the handiest web application frameworks that will help to expedite your web app, cutting development time and saving on resources - find out which ones we recommend for different purposes in this article.

Node.js - a JavaScript runtime

Node.js provides a clever JavaScript runtime that allows us to run JavaScript code on the server-side of web applications, which means we can have a full stack JavaScript application - both front-end and back-end.

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:

  • Microframeworks
  • 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-route` is 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.

  • **Full featured web application** - Sails.js / Meteor

If your goal is to build a complete web application, then, depending on the complexity, you should consider Sails.js / Meteor. Meteor is more complete, since it supports data synchronization with the client side app out of the box, but it is tied to a single database engine (MongoDB). You can also choose hybrid - use Sails.js for building the application with the help of a front-end JavaScript framework to deliver great user experience only on pages that require it (i.e. demand complex interactions).

Working with JavaScript both in the frontend as well as the backend of your application can make it a more cohesive experience for developers, managers, and other stakeholders - which is why Node.js is becoming so popular. To take full advantage of Node.js, we use microframeworks and/or full stack frameworks to bring a project to fruition. If you’d like to start using JavaScript in your web app’s backend and need a helping hand then email us at iRonin. Not only can we provide expert guidance but our team possesses superior development skills to give your project the edge.

Similar articles

Previous article

Rails Girls