Is Node.js Good for E-commerce? Building Online Store in 2021

E-commerce platform is a complex system from a technical perspective. To make all the pieces work together, you need a reliable technology that will support it. Node.js is fast and scalable, but how to make sure it’s the right match for your platform?

The Beauty of Building Apps with Node.js

Node.js is a Javascript environment that lets you develop performant and scalable applications. It’s a perfect match for applications such as real-time collaboration tools, chats, streaming apps or other applications that deal with multiple I/O operations. However, it doesn’t cope well with CPU-heavy software as the long-running calculations block incoming requests, which can lead to a drop in performance.


Node.js supports multitasking by giving better outcomes with lower costs. Comparing it to – say – PHP, it’s way more convenient. As the buyer’s journey at an e-commerce store involves numerous operations, such as adding things to the basket, changing product features, choosing payments etc., it’s crucial from the performance viewpoint that the technology serve such tasks efficiently. And Node.js effectively handles different operations conducted at the same time, which makes it a good choice for e-commerce.


Node.js enables quick scalability. In a short period, your e-commerce store can grow substantially. It is an important factor to consider when choosing the technology. Node has an inbuilt mechanism that helps to manage scalability and adjust it to your individual needs.

Big and Active Community

The Node.js community is a very active and vibrant group of developers who contribute to the constant improvement of Node.js. Thanks to their cooperation, the framework is well-documented, up-to-date and continuously supported, which makes the development much easier and faster. They produce a ton of ready solutions, codes in Github, plugins, modules and many more possibilities. In addition, if a problem pops up, chances are you already have the answer on StackOverflow.

Many Plugins and Packages in npm

Node.js comes with a great deal of packages that can be easily implemented in your app. That way, developers don’t need to write everything from scratch but can leverage reliable open-source solutions. It significantly increases the speed of development. There are great packages available for e-commerce too.

One Language on Back- and Front-end

Node.js is a JavaScript-based environment, and many popular front-end frameworks (such as React, Ember, Angular) use the very same language. Therefore, you can create applications which are isomorphic that is written in one language. It streamlines the development process, the communication between front- and back-end teams is way easier, and they can understand both sides of the codebase much better. Potentially, you might have a smaller and more efficient team that is easier to manage. Finally, with no technological diversity recruiting new people in case of scaling up won’t be a problem.

Tips and Things to Remember

After you weigh up all the options and decide to go for Node.js, there are a few things to consider about the development.

Choose the Right Solution

Depending on your needs, the number of features and the complexity of an application, you will have a bunch of options to develop your e-commerce store. There are a few ready solutions to create such an app including platforms such as Prime Fusion, Reaction Commerce and Naturally, you can also build an app from scratch if your project requires unique characteristics. Let’s go through all of the options.

  1. Prime Fusion
    Prime Fusion is a product fully based on MEAN stack, a full-stack javascript framework that includes MongoDB, Express, AngularJS, Node.js as well as GraphQL, webpack, React, Gulp, Babel and Mocha. All the above mentioned databases and frameworks provide developers with a complete set of tools to build a stable e-commerce platform. Prime Fusion can be easily modified and doesn’t require special knowledge about creating a store – everything comes with the framework.
  2. Reaction Commerce
    Reaction Commerce is an open-source, real-time platform based on Meteor Framework. It is a fast, flexible and scalable solution that plays nicely with npm, Docker and React. The codebase is modular, so you can tailor the solution to fit your needs. Everything can be extended, overwritten or installed as a package. It also provides extensive real-time analytics to help you make better business decisions.
  3. is also built around MEAN stack. It offers a flexible, scalable API and all basic functionalities you will need in your e-commerce store. The solution was built by a team of developers who had previously created a lot of e-commerce applications and then decided to take that existing code and make it open-source.
  4. Own solution
    The last option is to code your own solution that would be fully in line with all your needs. Building it from scratch will give you much bigger flexibility. However, it will take more time and money to create it and require more experience from developers.

Consider Technology Coherence

Node.js serves only as a backend for your e-commerce store, and you also need to think about what technologies you will use for other parts of the application. It’s important that all the frameworks and solutions stay consistent. That’s why the best option is to use a ready package offered by e-commerce platforms mentioned in the previous section. That way, you will avoid many problems that may appear when developing the app.

Is It a Good Choice?

In many cases, Node.js can give you higher performance than other technologies. It’s also proven that it’s a stable and fast solution for building e-commerce stores. It comes with a bunch of ready frameworks that make development easier and quicker. However, choosing stack is an individual case and depends on many factors.

What is Node.js used for?

We know JavaScript as a language to write once and run anywhere. It began its ascension with browsers, where JS became a standard language for manipulating web pages. Thereafter, it moved to the server-side and established itself on web servers. That entailed a capability to generate web pages on the server.

However, JavaScript’s first run at the backend was short-lived and has probably vanished from the developer community’s memory. As we go along, we’ll explore numerous types of JS employment, like writing a command line app or a specific search engine. Still, to build a general-purpose application using JS was a challenge. The wind of change blew when Node.js came out.

Node.js is not a JS framework

There are many web frameworks with underlying JavaScript. These include Angular and React, Meteor.js, Vue.js, and others. All of them contribute to the development process by increasing efficiency, safety, and cost-effectiveness. Although Node.js allows you to build platform-independent web apps, it is not a JS framework. The official description or title of this tool is a run-time environment which, in turn, means a bigger scope of implementation. On that account, uses of Node.js are not limited to web applications but also include microcontrollers, REST APIs, static file servers, OS wrappers, robots, and even drone programming. Instead of a listless request-reply message exchange pattern, the technology applies a progressive event-driven paradigm, which provides an event-loop ready to react to an event.

How it works

The essence of the technology is a highly customizable server engine that uses non-blocking event-based input/output model. It makes a kind of translation of JS into machine language which provides increased performance and agility. As a result, we get a run-time environment, where JS code moves fast in the server-to-client direction. With Node.js, JavaScript increased its capabilities from just building interactive websites to a broader scope of use cases that we’ll review later.

If you open the hood of Node.js, you’ll discover the realm of the event-loop. Traditional web-serving techniques stipulate a separate thread for each request. Henceforth, random access memory (RAM) experiences a huge load. As for Node.js web development, the non-blocking input/output model needs a single thread to support multiple concurrent requests in the event-loop without clogging RAM. Simply put, when data exists, it is simply transmitted without constant querying. All asynchronous tasks are taken by the event-loop, which ensures a high level of responsiveness and, hence, speed.

Pros & Cons

In our article dedicated to comparing Python vs. Ruby vs. Node.js, we made a short introduction to the advantages/disadvantages of the run-time environment. Well, if you want to know what is Node.js best used for, a detailed review of its strengths and weaknesses is obligatory.

– Full stack JavaScript development
Node.js has paved the way for JS to the server side. Now, companies and startups can build both the backend and frontend of their products with only one scripting language. In terms of development, you cut your time expenses, as well as recruiting efforts, since a team of JS-savvy engineers might be enough to succeed.
– Asynchronous non-blocking input/output
With Node.js, you have no trouble processing hundreds of thousands of simultaneous requests. The data flow experiences no interruption, which, in practice, gives less RAM consumption and faster performance.
– V8 engine
Though Node.js is not a Chevy Corvette, it has a V8 engine as well. However, it is a JS engine developed by Google. V8 converts JS code into machine code that provides extremely fast execution.
– Microservices architecture
In today’s reality, architecture based on microservices is gaining popularity over the monolithic one. For this reason, a variety of well-known companies including Netflix are taking up the practice of splitting an app into smaller services. Besides, the technology offers ample ready-to-use modules, as well as an event-driven I/O model, to implement microservices solutions.
– Rich ecosystem
The availability of ready-to-use tools for building Node applications is a significant booster for development performance. For this reason, you should learn three letters – N, P, and M. They refer to the JS package manager, which amounts to over 700K building blocks so far. NPM allows you to search, install, share, and reuse lines of code.
– Heavy computations incapacity
Node.js is a great solution for building complex projects. However, it is not an option when you need to deal with CPU-intensive tasks. Due to incoming request blockage by heavy computations, there is a significant loss in performance. On that account, it is not a fit for long-running calculations.
– Callback hell
This issue can affect the quality of your JS code and trigger other declines such as development slowdowns and cost increases. Callback hell is a situation caused by execution of multiple asynchronous operations where myriad nested callbacks end up a callback function. Well, starting with the 7th release, you have the async/await feature to mitigate problems with callbacks. Unfortunately, they do not promise to avoid them completely.

What can you do with Node.js

Early on, we made a passing mention of possible Node.js use cases. Now, we can explore this topic in detail. You know that the bulk of the technology’s popularity falls to the backend development. Frontend, as well as full stack usage of the tool, falls behind a bit. According to the latest survey made by Node.js Foundation, web applications are the top use case with the share of 85%. Taking into account all the strengths and weaknesses of this JS run-time environment, we composed a list of the hands-on solutions where you can leverage the technology.

Complex SPAs

A single-page app (SPA) involves the allocation of an entire application on one page, whereas the UX is akin to a desktop application. This type of product is popular for building online text/drawing tools, social networking or mail solutions, and numerous versatile websites. In that case, Node.js app development is a good fit for making SPAs due to its asynchronous data flow on the backend. The event loop “catches” simultaneous client’s requests which provides a smooth data update. In practice, it eliminates the necessity of refreshing the page every time to get new data. Besides, a bunch of SPAs have been created with different JS frameworks/libraries including React, Meteor, Vue.js, Angular, etc. JavaScript is a common language between these tools and Node.js which improves the development process by reusability of structures and approaches both on the frontend and backend.


For those out of step, RTA refers to a real-time app. I bet that most of you employ this type of applications on a daily basis. To name a few, Google Doc/Spreadsheets, as well as Slack, represent this use case. As a rule, collaborative services, project management tools, video/audio conferencing solutions and other RTAs require heavy input/output operations. Again, the asynchronous event-driven nature plus event API and websockets offered by Node.js ensure a seamless server operation (no hangup) and instant data update. Real-time chats are also tightly related to the technology, but they deserve a separate paragraph below.

Chat rooms

This use case is the most typical RTA. Moreover, it is definitely a sweet-spot when we talk about Node.js implementation. If you aim at this type of product, you are likely to set such requirements as high traffic capacity, lightweight, as well as intense data flow. All these can be achieved in full using Node.js combined with some JS framework like Express.js on the backend. The already mentioned websockets play a key role in receiving/forwarding messages within the chat room environment.

Browser Games

Chat rooms are not much-in-demand independently except for their implementation as a component in online games. Node.js game development is another attractive use case. Actually, the combination of the technology with HTML5 and JS tooling (, Express.js, etc.) allows you to construct RT browser games such as Ancient Beast, PaintWar, voxel shooting, Anagrammatix and many others.

Data streaming apps

Another product type where Node.js is used is a streaming app. The technology’s selling point is the ability to process data during the uploading time. Using it, you can transmit particular parts of the content and keep the connection open to download other components when necessary. In that context, Node.js streaming apps deal with not only video and audio data. Other forms are also available for input/output in real time.


Application programming interfaces (APIs) based on representational state transfer (REST) hold a fundamental position in building modern enterprise software architectures. The reason is a wide usage of the HTTP protocol. Besides, REST APIs are in demand in view of a trend towards microservices design patterns. Node.js ecosystem offers Express.js framework to build the lightweight and fast REST APIs. As for the benefits compared to other technologies – simple exposure of JSON objects with a REST API and no worries about conversion between JSON and MongoDB (with other databases that do not store data using JSON like PostgreSQL, transformation is necessary).

Server-side web apps

Express.js can complement Node.js for building web apps on the server side. Of course, it is worth mentioning that no CPU-heavy operations should be expected. Besides, a server-side web app is not an accustomed Node.js use-case.

Command line tools

This use case rests upon the Node.js’ aptitude for writing command-line scripts. On the web, there are plenty of tutorials on building hands-on examples. The technology’s expansive ecosystem is always an advantage, and you will easily find the right packages to make your CLI app.

Hardware programming

Hardware programming is another answer to the question “What does Node.js do?”. The hardware includes robots, quadcopters, various embedded devices and the Internet of things (IoT). IoT can get the most out of Node.js on the server to process numerous simultaneous requests sent by lots and lots of peripheral devices. The JS run-time environment is a kind of interlayer between devices and DBs, and its asynchronous event-driven architecture enables a fast data flow.

Robotics is also an attractive area, which is now open for those having basic JavaScript knowledge. With Node.js and the appropriate frameworks (Johnny-Five, Cylon.js), you have opportunity to delve into programming robots and JS-controlled devices like NodeBots.

What is NOT the best purpose of Node.js?

Considering the use cases described above, you may think that this run-time environment is a silver bullet for any project or idea. I wish! Unfortunately, there are cases when it is better to opt for Ruby on Rails or another technology instead.

CPU-heavy server-side computation

We’ve already said that heavy computations are not a strength of the technology. CPU-intensive operations jeopardize the blockage of the incoming requests and pushing the thread into number-crunching. Thus, all throughput benefits Node.js offers will fall into oblivion.

CRUD apps

A CRUD app model refers to 4 functionality types (Create, Read, Update, Delete) implemented in apps with a relational database. When your goal is a simple CRUD app unencumbered with a separate API with a direct-from-server data route, Node.js might be a more-than-enough solution. On the other hand, to build a server for gathering analytical events, the JS run-time environment technology will be a perfect fit due to numerous parallel requests regardless of the type of DB is used.

Who uses Node.js

Not only independent developers and small dev teams choose the technology for their needs. Providing long-term support, Node.js attracts big companies as well. According to 2018 Node.js User Survey Report, the number of websites built with the tool exceeds 80K, and companies that use Node.js include IBM, Sony, SkyCatch, Uber, PayPal, SAP, and many many others. Check out reputable Node.js app examples we’ve blogged about.

Traditionally, the US is ahead of the pack by international presence (26%) of the technology. The second country in the list of Node.js users is India (10%) followed by Germany and Canada (6%) with a little lag. Globalization of users is expressed by the total number of countries (over 100) they reside in and languages (over 60) they speak. In that context, Europe is the leading hangout of Node.js developers so far.

Most Node.js users opt for Amazon Web Services (AWS) to deploy their products. Its competitors represented by Heroku, Google Cloud, and Digital Ocean Railsware are lagging behind not only AWS but also the on-premise infrastructure deployment, which experiences growth due to the rising Node.js popularity among big companies. Railsware, in turn, has posted our review of the best hosting services for Node.js.

Bottom Line

According to statistics, three in four engineers that employ this tech stack go into backend or full stack development. At the same time, along with a thumping majority of web apps built with the JS run-time environment, there are many other options for how to use Node.js in the digital world. Some of them you have discovered in this article, while even more information can be drawn out of the best Node.js books. Your next or current project, whether it is involved in programming robots/drones/devices or building a complex single page/real-time/data streaming app or even a huge IoT system will benefit from this tech stack. Eventually, you’ll ask yourself “Why not use Node.js?”, and take it for a spin.

About Classes in Node.js

Classes in Node.js

Preface. This is my first article and English is not my native language. At the beginning, I wrote it for myself, just for memory, but now I decided to share it. Maybe it could be useful for someone. So, don’t judge me too strictly.

Classes is the most important fundamental concept in Object Oriented Programming (OOP). Therefore, it is important to know how to work with them. ES6 gives us very nice new syntax for class declaration.

class Class1{
        console.log(‘Initialize Class1 object’);
        console.log(‘Arg=’, arg);

To create a new object:

const obj1 = new Class1(5);

Why we using ‘const’? It is important to understand. Variable obj1 keeps link to an object. All changes in our object will be in its properties. That is why obj1 never changes and we can use const declaration.

Professional developing demands good programming style. When we work with classes and objects good style is to keep every class in a separate file. It makes code clearer for understanding and allows encapsulation principles. And here we get a little problem. Node.js module mechanism allows us to export variables, functions and objects, but not classes. That’s why realization is a little tricky. First let’s make a file app.js, directory classes and file Class1.js in it. app.js:

‘use strict’
const Class1 = require(“./classes/Class1”);

const obj1 = new Class1(5);
console.log(`Object property = ${obj1.val}`);

In file with class declaration first we will declare internal empty object. It will be a container for our exported class.


‘use strict’

const internal = {};

module.exports = internal.Class1 = class{
        console.log('Initialize Class1 object’);
        this.val = arg;

Now, if we start our application in terminal we will get this:

$ node app
Initialize Class1 object
Object property = 5

It means that we successfully exported our class, imported it and created an object with val property which is equals to 5. Congratulations. Furthermore, we can implement public and private properties and method in our class. To do this, all privates we just declare in a class file out of class declaration. New class file:

'use strict'

const internal = {};

module.exports = internal.Class1 = class {
    console.log('Initialize Class1 object');
    this.val = arg;
    console.log(`Public method with the help of private got this value: ${_method(x)}`);

let _val = 12;

function _method(x){
  return _val * x;

Now, pubMethod is public and we can invoke it through our object obj1.pubMethod(28);and _method and _val is private and we can use it only inside the methods of our class. Let’s update our app.js and start the application: app.js

'use strict'
const Class1 = require("./classes/Class1");

const obj1 = new Class1(5);
console.log('Object property = ', obj1.val);
$ node app
Initialize Class1 object
Object property =  5
Public method with the help of private got this value: 336

When I found this for the first time, I was very happy 🙂

This is just a carcass, and I will try to wright a practical realization of this methodic in next article. It can be used in modeling in RESTful application, for example. on