An Introduction to Node.js

  • 4 minute read

Decoupled applications are increasing in popularity as brand experiences continue to move beyond the traditional website. Although your content management system (CMS) might house your content alongside Drupal, it doesn’t just stay put. APIs are making calls to extend that content to things like digital signage, kiosks, mobile … really, the sky’s the limit (as long as there’s an API).

Decoupled applications are nothing new; Acquia CTO and Founder Dries Buytaert has been writing about this for at least two years. And we’ve been working with clients, such as Princess Cruises and Powdr, to build decoupled experiences and applications for their customers.

Why is decoupled Drupal becoming so popular? We see a number of benefits both from our customers’ perspective as well as from our partners. The primary use case for decoupled relates to when our customers need a single source of truth for content that supports multiple applications. Drupal’s API-first architecture makes this work very well with some real benefits for developers.

First, if you have a relational content model, Drupal provides a robust CMS to serve as a repository for your applications. Content authoring and management occurs in Drupal and can be served to one or many applications. The API-first architecture of Drupal 8 provides a robust repository for serving this use case.

Second, if your development team is working in a differentiated development methodology where front-end and back-end development teams are working simultaneously, Drupal makes it easy for teams to map the content model to the API. For the nontechnical, this means teams can divide and conquer to deliver applications faster.

Why Node.js and Drupal are a great match

Drupal is open source / roadmap has focused on enabling decoupled projects and making them easier (Reservoir); Node.js is popular run time and connects to multiple front-end frameworks, such as Ember, Angular and React. A great use case is an editorial website; the back end manages content, and the front end brings it to life.

Drupal’s open source framework and flexibility makes it a top choice for building decoupled experiences and applications. But with flexibility comes work; how can building decoupled Drupal applications become easier? Node.js.

In super simple, non-technical terms, Node.js is like a chef that reads the JavaScript cookbook to make the meal.

Node.js is an open source server framework designed to build scalable network applications. It can run on various platforms from Linux to Mac OS X and uses JavaScript on the server and it was created for efficiency. Node.js eliminates the waiting, and simply continues with the next request.

Node.js runs single-threaded, non-blocking, asynchronous programming, which is very memory efficient

  • Node.js can generate dynamic page content
  • Node.js can create, open, read, write, delete, and close files on the server
  • Node.js can collect form data
  • Node.js can add, delete, modify data in your database

 

So what does this look like? Content, like an article for example, that lives within your CMS have a type, but also need to show up on mobile. To do this, that content is maintained in the back end in one place, and then maintained with JavaScript on the front-end. The reason for using JavaScript is JS is designed for better usability.

JavaScript is huge, which means more talent out there to create engaging digital experiences and really cool decoupled applications. The bottom line is supporting JavaScript and frameworks like ember, react, Angular and of course, node.js, makes your platform better.