Native Node.js Extensions
Native addons and Node-API compatibility.
Q80: What are C++ Addons and Node-API (N-API) in Node.js?
C++ Addons are dynamically linked shared objects written in C++ that can be loaded into Node.js using require(). They provide bindings between JavaScript and native system libraries for performance-critical tasks. Node-API (formerly N-API) is an Application Programming Interface (API) that abstracts the underlying V8 JavaScript engine. Node-API guarantees Application Binary Interface (ABI) stability across Node.js versions, meaning compiled native addons do not need to be recompiled when upgrading the Node.js runtime version.
Key Takeaways
- C++ Addons enable direct interaction with system-level libraries and native machine execution speed.
- Node-API provides ABI stability, allowing native modules to work across different Node.js major versions without recompilation.
Knowledge Check
What primary problem does Node-API (N-API) solve for native C++ addon developers?