Use of Node JS for Frontend

Sahil Thakral picture Sahil Thakral · Jan 24, 2016 · Viewed 7.4k times · Source

I have heard about Node.js being used in the frontend side of the application as opposed to the backend side, but I cannot find any use cases for which it can be used. Can somebody explain the use cases for which Node.js is used in the frontend.

Also for a fairly complex system such as a CMS(Content Management System) for an e-commerce site, would Node.js be the right choice?

Thanks in advance

Answer

LanceLafontaine picture LanceLafontaine · Jan 24, 2016

Node.js is a javascript runtime that uses the Chrome V8 javascript engine. The front-end already uses a javascript engine on the browser (V8 for Chrome, SpiderMonkey for Firefox, Chakra for Edge), so whether Javascript is running in the browser on in Node.js, you can expect very similar environments.

However, you might be interested in using Node.js modules on the front-end. The modules are packaged using a tool called npm. You can use module loaders or bundlers like Browserify, webpack, or Rollup.js to accomplish this.