Documentation of native addon made with Napi and **Cmake** to package c++ code.
Table of contents
Node.js can communicate with c++ in three ways, first calling executable file directly from node but it has almost zero flexibility. Second options is dll and they can do the job but has moderate flexibility. Third option is native addons/extensions, addons are fully customizable and they can be called dynamically and in web workers too. Node.js napi(next generation api) makes addon independent of node version and Cmake facilitate c++ code compilation. we are using web worker to call c++ native addon, so we can be sure that our app UI will not get blocked because of c++ processes.
<aside> 💡 Native addon folder doesn't contain c++ source code to build native addon directly, to add those files, you need to **install project,** then you can install native addon.
</aside>
Native addon mainly needs a package.json to configure addon information, CMakeLists.txt for c++ code build instructions and source files will be placed in "src" folder of native addon. Source folder includes AddonAPI files consisting Napi wrappers for c++ functions. Wrappers catch node argument and convert them in c++ type, they can pass on exception and much more.