Why do we need C++ Addons in Node.js?

Technology CommunityCategory: Node.jsWhy do we need C++ Addons in Node.js?
VietMX Staff asked 3 years ago

Node.js Addons are dynamically-linked shared objects, written in C++, that can be loaded into Node.js using the require() function, and used just as if they were an ordinary Node.js module. They are used primarily to provide an interface between JavaScript running in Node.js and C/C++ libraries.

There can be many reasons to write nodejs addons: 1. You may want to access some native apis that is difficult using JS alone. 2. You may want to integrate a third party library written in C/C++ and use it directly in Node.js. 3. You may want to rewrite some of the modules in C++ for performance reasons.

N-API (pronounced N as in the letter, followed by API) is an API for building native Addons.