Node js frameworks

Node.js Frameworks Comparison for Your Back-end Solution: Express.js, Meteor.js, Sails.js, and more

Gone are the days when JavaScript was the language of client-side browser applications only. Today, full-stack JS is a common approach to building enterprise-scale systems with rich capabilities both on front and back-end. This became possible after Node.js, a runtime environment, was presented in 2009. Unlike Angular, another JavaScript tool, Node.js extends the capacities of JavaScript to enable its use for server-side work.

According to the 2017 StackOverflow survey, not only is JavaScript the most commonly used language (62.5 percent from 36,625 responses) but Node.js is the most popular technology (47.1 percent from 20,229 responses). Such popularity transitions into the proliferation of a versatile toolset that can be used with Node.js.

To learn more about Node.js advantages and disadvantages, consider checking our video.

Node.js in a nutshell (if you like the video, please subscribe as we constantly release tech explainer content)



Using frameworks over pure Node.js

There’s an ongoing debate around the term framework.  Frameworks, by definition, are sets of conventions to interpret code. But in layman’s terms, frameworks warp the original development environment (e.g. Node.js) to bring more convenience to software engineers.

The convenience, in this case, has a highly variative meaning that depends on your project length, complexity, scalability, and ultimately the engineering preferences. That’s why, every popular technology - JavaScript, Node.js, or other - is usually surrounded by a buzzing community that continuously suggests new frameworks for different use cases.  So, Node.js frameworks come in different flavors and usually, from the technical standpoint, they are divided into 4 main groups:

MVC frameworks. The name says it all. These frameworks provide a great deal of development freedom and flexibility without additions and are based on the Model-View-Controller design pattern.

Full-stack MVC frameworks. These instruments come bundled with libraries, integrations, template engines, scaffolding, and other add-ons that allow engineers to automate their work, but usually at the cost of flexibility.

REST API frameworks. These tools streamline REST API server development and can be used in combination with any other group of frameworks.

Others. And there are many middleware, libraries, and other specific solutions that can be considered frameworks to some extent. We’ll talk about them in a bit.

That said, we’ve chosen the most popular Node.js server-side frameworks according to the number of Git stars they have. The frameworks either expand the original Node.js or provide lightweight and flexible development with a limited number of features. We’ll also try to provide hints on when to use this or that framework. Express is the most popular Node.js framework. If you aren’t familiar with the MEAN concept, E here stands for Express. And MEAN is a traditional full stack of technologies sufficient to cover main software engineering tasks: MongoDB - a database, Express - back-end middleware, Angular - front-end, Node.js - a runtime environment.

Middleware simply means that the framework provides instruments for building the bridge between the server side with a database and a client side. Express is suggested as a lightweight, flexible, and unopinionated framework. It's unopinionated because a software engineer isn’t limited to using hardwired development practices, so it provides much freedom. For instance, Express doesn’t dictate any of the design patterns (MVC, MVP, MVVM, etc.) This allows engineers to build applications their way. And yet Express is commonly applied within the MVC pattern.

The freedom also extends to database integration. While MEAN contains MongoDB, Express doesn’t require specific DB integration out of the box. Developers can choose whichever data storage technology they prefer and install the respective package as a database driver.

Main Express features to look at

Freedom. Developers are only limited by their skillsets and preferences. This also ensures a gentle learning curve for newcomers.

High performance. Node.js is famous for its performance. Express provides just a thin layer over it without compromising performance.

Large community. Express is a technology you should consider by default as it remains the common practice among most engineers.

Express.js use cases

If you run a small engineering team and your product isn’t likely to expand into some enterprise-scale monstrosity soon, opt for Express. It’s the best fit for from-scratch projects that don’t suffer the legacy burden. But as your project and the team grows, the lack of standards may inadvertently lead to code management hell. Beware.

Meteor: automated all-in-one

Meteor is another popular framework, which sits on the opposite pole of the Node.js globe. Unlike Express.js, Meteor takes standardization and out-of-the-box philosophy to the extreme. The package arms an engineer with integration tools that are sufficient for building server, mobile, web, and desktop apps. Meteor integrates with Angular or React.JS to connect Node.js back-end with applications on the front-end. It uses MongoDB as storage and can be integrated with Cordova to build hybrid applications using HTML, CSS, and JS running through WebView. While you can swap most parts from the stack, this packaging streamlines much of the ground-work.

On top of that, Meteor is the opinionated MVC framework. Unlike unpoinionated frameworks, it doesn’t leave much freedom to engineers but ensures a high development pace due to automation.

Main Meteor features to look at

Magic of data synchronization. Meteor automatically enables bi-directional data synchronization between a client application and a server. This is achieved by creating a mini-database copy on the client side that contains a small chunk of data that a user subscribed to. Once a client requests new data, the system automatically connects it with the server to retrieve requested data from the DB. As changes on one end are applied, they are automatically and instantly reflected on the other end. Engineers don’t have to manually set up synchronization.

Out-of-the-box integration. That’s perhaps the main quality of Meteor. It comes as an all-in-one and reduces much of the integration effort unless engineers opt for technologies beyond the vanilla bundle.

Build automation. The engineers behind Meteor brag about it having a packaging system that automates packaging the same code source into multiple end platforms, be that mobile, web, or even desktop. For instance, with the help of Cordova, a hybrid mobile development tool, you can tweak and package HTML/JavaScript/CSS code for iOS and Android without much effort.

Meteor.js use cases

Being highly automated, Meteor encourages fast prototyping and building MVPs (minimum viable products). You quickly build your app across platforms, see how it looks and feels, iteratively update it, and then go live to catch the initial feedback. It’s not that you can’t use it for business-scale applications, it’s rather that your engineering team will likely suffer from scalability issues in the longer run. Building hybrid apps, for instance, usually, jeopardizes user experience as apps appear laggy and generally slow. Automated data synchronization can also become a bottleneck, once your user base reaches enterprise-scale loads.

Sails.js: MVC framework that holds the balance

Sails.js is little more standartized than Express, but it’s basically an extended version of the latter which adds some higher-level capabilities that increase development speed compared to Express. If your engineers are familiar with Laravel or Ruby-on-Rails development, Sails won’t raise a high adoption barrier for them. It applies a traditional Model-View-Controller design, which makes development organized and intuitive. The model covers data management, the view is in charge of output representation, and the controller operates server-side business logic and acts as a layer between view and data.

Sails.js takes the middle ground between automation and engineering freedom, which makes it perhaps one of the most balanced options in Node.js development. Although your engineers might not necessarily be Ruby experts, MVC is common enough to claim that Sails has a gentle learning curve. Let’s have a look at the most productive sides of Sails.

Main Sails.js features to look at

The real-time connection between server and client. Sails.js comes bundled with Socket.io, which is a popular engine for real-time, event-based communication between server and client. It greatly simplifies server connection for real-time features like messaging or collaborative tools.

ORM for multiple databases. Sails also has an object-relational mapping (ORM) tool called Waterline. It’s a layer over the database that simplifies DB-communication relieving developers from configuring variable database queries for SQL and NoSQL databases. Basically, the ORM permits the use of any database by making small changes in the Waterline adapter.

Rapid REST API development. Sails generates REST APIs automatically allowing developers to further configure what they need to be generated. This makes API configuration ridiculously fast.

Sails.js use cases

Some engineers claim that Sails is the best framework you can find for Node.js development. While Sails is good for many tasks, it will really shine with the apps that will have instant messaging or real-time event-based updates. These are messengers or applications that involve messaging capacities, various dashboards and streaming analytics with constantly updating charts, collaborative tools for project management and text editing. The use cases can even stretch to multiplayer games.

Koa.js: more minimalistic, no callback hell

Koa is another incarnation of minimalism by the developers of Express. The goal of Koa is to reduce the middleware bundle that was in Express and give even more freedom to engineers without any automation. Basically, it allows for controlling everything.

Perhaps, the keyword that you can use to describe Koa is lightweight as it has only 550 lines of code. However, Koa still has a smaller than Express community and lacks compatibility with other Node.js systems. It’s also not as simple as Express and may have quite a steep learning curve.

Main Koa.js features to look at

Combating callback hell. One of the problems that JavaScript developers stumble over is “callback hell.” And Koa aims at combating it. Callbacks are functions that are triggered only when specific events happen. The rest of the time they don’t spend waiting for the triggering event. These are called asynchronous callbacks and they are actively used in JavaScript. Callback hell results when the sequences of callbacks are too long, complex, and the execution of code must run all the way from top to bottom.

callback hell in JavaScript code

Koa utilizes the ES6 Generator which tackles this problem. It allows the system to stop execution if there’s a blocking issue on some level and then, once the issue is resolved, resume execution.

Minimalism. Let’s reiterate. Minimalism defines the modularity and the lightweight nature of the framework, which means that engineers - once they tackle the specifics - won’t spend much time on code management and will use only the features they need.

Koa.js use cases

The framework is a good fit for the projects that are built from the ground up using the microservices architecture. The ES6 Generator ensures that different services within such architecture work properly without any callback hell management. Another common use case is creating APIs for a distributed system.

Keystone.js: not-WordPress CMS with Express on the back-end

The reason we decided to talk about Keystone.js is simple. The project has 11,116 stars on Git and stands among the top Node.js frameworks. But this one is also special. It challenges the CMS-dominance of WordPress suggesting a Node.js-driven CMS and application development environment.

Technically, Keystone is a full-stack framework. It contains configured MVC-based Express in its core and uses MongoDB as storage. It’s easy to install and it also suggests a mild learning curve for back-end engineers. This can’t be said about front-end developers though. If they aren’t familiar with the MVC design, it may take some time to learn Keystone before creating CMS.

But the main differentiating point is the set of built-in features that automate and streamline CMS engineering. Let’s have a look at them.

Main Keystone.js features to look at

Auto-generated admin UI. It's self-explanatory. Keystone will generate admin UI, which simplifies things during development and reduces the effort required to build admin UI for non-technical users after production.

Automatic forms processing. Engineers must define data models and the framework will automatically enable forms validations, image uploads, and database updates.

Out-of-the-box authentication and session management.  There’s no need to spend much time building and plug sign in, sign out, and encryption features for password fields come with the package.

Email integration. And finally, the framework features email capacities that streamline email management engineering. If you like Mailchimp, you'll be happy to know it works with the related Mandrill service.

Keystone.js use cases

The answer is obvious. If you hate Wordpress for its laggy flow and messy management, try Keystone. Although WordPress has released Calypso, which is a JavaScript-driven environment for WordPress users with multiple content websites to manage, it’s still less configurable than what Keystone provides. The drawback here is the community and pre-built modules. WordPress is significant not because of the underlying technology, but due to its ecosystem, something you won’t have with Keystone.

LoopBack.js: automatic REST API generator

LoopBack is the brightest representative of REST API frameworks. It’s built on top of Express and allows engineers to create APIs that connect server side with client apps in a semi-automatic manner.

Despite the fact that LoopBack comes bundled with Node.js modules, it’s still fully configurable if needed. The engineers behind the framework follow the convention-over-configuration mantra. This basically means that engineers aren’t required to make many decisions when working with the tool, and that flexibility isn't sacrificed.

Engineers are fond of good code management capacities and the Explorer feature that allows for browsing your APIs. The tool is simple to grasp as it follows the back-end agnostic philosophy and requires little to no-code composing.

Main LoopBack.js features to look at

REST API generation. Semi-automated API generation is what allows LoopBack users to avoid configuring models, security, parameters, and REST endpoints. This significantly reduces time spent on creating REST APIs compared to the Express process.

API Explorer. The feature allows the user to browse APIs, manage them, and avoid creating API documentation.

LoopBack.js use cases

As you’ve guessed, LoopBack would be the best tool to work with when your engineering heavily relies on using REST APIs and you want to streamline their development up to highly automated workflow.

Choosing the right framework

When choosing the framework for your next Node.js project, we recommend adhering to the following steps to help you make the right choice:

Assess your engineering team. If you just embark on Node.js development, it’s better to stick with simple and commonly used frameworks that don’t require long onboarding. Standardized and complex full-stack solutions will definitely require more time.

Define the project specifics. Consider how the framework features match your product. If you have an experienced team of engineers and you want to build a prototype or MVC fast, opt for more standartized and full-stack solutions. If you have long-term development, it’s better to stick with lightweight and flexible instruments.

Research limitations and community support. Any software engineering tool thrives only if it’s backed by powerful community. While there are great frameworks, the lack of peer support may become a routine blocker as your engineers will have to figure out problems for themselves.

Consider the maturity of a framework. Some of the tools are still in development. They may suffer from bugs or some features may be still in development. Assess those to ensure that you get all the feature-list that you need.

If you’re still unsure about Node.js as the underlying server-side technology for your product, consider reading our Node.js pros and cons story to get a broader view on the topic.

Also, consider checking mobile and web tools comparison articles:

Xamarin vs Flutter

Swift vs Objective-C

React vs Angular

Top 20 tools for Android development

AngularJS vs Knockout.js vs Vue.js vs Backbone.js

Comments