# nodejs/node-addon-api

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/nodejs-node-addon-api).**

2,400 stars · 499 forks · C++ · MIT

## Links

- GitHub: https://github.com/nodejs/node-addon-api
- awesome-repositories: https://awesome-repositories.com/repository/nodejs-node-addon-api.md

## Topics

`node` `nodejs`

## Description

This project provides a header-only C++ wrapper for the Node-API, serving as a framework for building high-performance native addons for Node.js. It acts as a bridge between C++ and JavaScript, offering an object-oriented interface that simplifies the creation of compiled extensions while managing the complexities of the language boundary.

The library distinguishes itself by providing type-safe abstractions for data marshalling and memory management, ensuring that native and script-side objects are tracked and reclaimed correctly. It includes mechanisms for coordinating asynchronous tasks between background threads and the main event loop, preventing data corruption while offloading intensive computations. Furthermore, it maps native exceptions to standard script error types, ensuring consistent diagnostic reporting and failure handling.

Beyond its core bridging capabilities, the project supports the full lifecycle of native development, including the exposure of C++ classes and methods to the JavaScript runtime. It provides tools for managing environment lifecycles, automating code migrations, and executing performance benchmarks to evaluate native component behavior.

## Tags

### Programming Languages & Runtimes

- [Native Addon Frameworks](https://awesome-repositories.com/f/programming-languages-runtimes/c-library-embedding/runtime-embedding/webassembly-engine-embedding/javascript-engine-embedding/native-c-extension-apis/native-addon-frameworks.md) — Provides a framework for building high-performance native addons for Node.js by wrapping native interfaces into object-oriented structures. ([source](https://github.com/nodejs/node-addon-api#readme))
- [Node.js Native Addons](https://awesome-repositories.com/f/programming-languages-runtimes/node-js-native-addons.md) — Builds high-performance compiled extensions for Node.js using C++ to execute intensive logic.
- [C-API Wrappers](https://awesome-repositories.com/f/programming-languages-runtimes/c-api-wrappers.md) — Provides a type-safe object-oriented interface that simplifies interaction with low-level native APIs.
- [Cross-Language Data Exchange](https://awesome-repositories.com/f/programming-languages-runtimes/cross-language-data-exchange.md) — Facilitates seamless data exchange and translation between native C++ primitives and JavaScript objects.
- [Native C-JavaScript Bridges](https://awesome-repositories.com/f/programming-languages-runtimes/java-virtual-machine-bridges/javascript-bridges/native-c-javascript-bridges.md) — Provides abstractions for managing memory, data conversion, and task execution across the C++ and JavaScript boundary.
- [Foreign Function Interfaces](https://awesome-repositories.com/f/programming-languages-runtimes/language-interoperability/foreign-function-interfaces.md) — Enables the execution of compiled native code within a managed runtime by mapping data types and function calls.
- [Node-API Bindings](https://awesome-repositories.com/f/programming-languages-runtimes/language-interoperability/native-c-interoperability/c-function-bindings/node-api-bindings.md) — Provides a header-only object-oriented interface for building native Node.js addons using the Node-API.
- [Native Memory Lifecycle Management](https://awesome-repositories.com/f/programming-languages-runtimes/language-interoperability/native-c-interoperability/native-memory-lifecycle-management.md) — Tracks and manages the memory and lifecycle of native C++ objects and JavaScript references to prevent leaks.
- [Native Addon Abstraction Frameworks](https://awesome-repositories.com/f/programming-languages-runtimes/node-js-native-addons/native-addon-abstraction-frameworks.md) — Provides a toolkit for exposing high-performance C++ logic and data structures to the JavaScript runtime.
- [Error-to-Exception Mappings](https://awesome-repositories.com/f/programming-languages-runtimes/async-runtime-bridges/cross-language-async-bridges/error-to-exception-mappings.md) — Maps internal C++ errors to standard JavaScript exceptions for robust failure management.
- [JavaScript Data Types and Structures](https://awesome-repositories.com/f/programming-languages-runtimes/javascript-data-types-and-structures.md) — Provides a type-safe interface for manipulating JavaScript primitives, objects, and buffers within native C++ code. ([source](https://github.com/nodejs/node-addon-api/blob/main/CHANGELOG.md))
- [JavaScript Exception Handling](https://awesome-repositories.com/f/programming-languages-runtimes/javascript-interop/javascript-exception-handling.md) — Translates native exceptions into JavaScript errors and provides mechanisms to manage error states across the language boundary. ([source](https://github.com/nodejs/node-addon-api/blob/main/CHANGELOG.md))
- [JavaScript Object References](https://awesome-repositories.com/f/programming-languages-runtimes/javascript-interop/javascript-object-references.md) — Tracks and releases native references to JavaScript objects to ensure memory is reclaimed correctly. ([source](https://github.com/nodejs/node-addon-api/blob/main/doc/README.md))
- [Native Class Wrappers](https://awesome-repositories.com/f/programming-languages-runtimes/language-interoperability/interoperability/javascript-to-native-bridges/native-class-wrappers.md) — Wraps native class methods into accessible objects so that developers can instantiate and manipulate complex logic directly from within the runtime. ([source](https://github.com/nodejs/node-addon-api/tree/main/doc))
- [Native Object Wrapping](https://awesome-repositories.com/f/programming-languages-runtimes/native-object-wrapping.md) — Exposes native class instances to the runtime so that developers can create, modify, and pass complex data structures. ([source](https://github.com/nodejs/node-addon-api/blob/main/doc/README.md))
- [Native Object Finalizers](https://awesome-repositories.com/f/programming-languages-runtimes/native-object-wrapping/native-object-finalizers.md) — Hooks into the garbage collection process to trigger cleanup routines for native resources once their corresponding script-side objects are destroyed.
- [V8 Object Wrapping](https://awesome-repositories.com/f/programming-languages-runtimes/object-lifecycle-managers/v8-object-wrapping.md) — Wraps native C++ classes as JavaScript objects with integrated lifecycle and memory management. ([source](https://github.com/nodejs/node-addon-api/blob/main/CHANGELOG.md))
- [Object Lifetime Management](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/programming-languages/language-specific-resources/language-tutorials/c-c-tutorials/object-management/object-lifetime-management.md) — Manages the lifecycle of native objects and memory buffers to ensure they are garbage collected when no longer referenced. ([source](https://github.com/nodejs/node-addon-api/tree/main/doc))

### Operating Systems & Systems Programming

- [Asynchronous Task Execution](https://awesome-repositories.com/f/operating-systems-systems-programming/asynchronous-task-execution.md) — Offloads computationally expensive operations to background threads and returns results to the main event loop.
- [Reference Counting](https://awesome-repositories.com/f/operating-systems-systems-programming/kernel-core-internals/process-and-memory-management/memory-management/automated-reclamation-systems/reference-counting.md) — Tracks the lifecycle of native and script-side objects to ensure resources are reclaimed automatically when they are no longer in use.
- [Native Logic Integrations](https://awesome-repositories.com/f/operating-systems-systems-programming/native-logic-integrations.md) — Exposes native code and data structures through a standard interface to allow high-performance execution of compiled logic. ([source](https://github.com/nodejs/node-addon-api/blob/main/README.md))

### Data & Databases

- [Native Data Marshallers](https://awesome-repositories.com/f/data-databases/data-type-mappings/native-data-marshallers.md) — Translates between native primitives and script-based data structures to facilitate seamless and reliable information exchange.
- [Script-to-Native Type Mappings](https://awesome-repositories.com/f/data-databases/type-mapping-frameworks/script-to-native-type-mappings.md) — Translates between native primitives and script-based objects to facilitate seamless data exchange across the language boundary. ([source](https://github.com/nodejs/node-addon-api/tree/main/doc))

### DevOps & Infrastructure

- [Thread Pool Offloading](https://awesome-repositories.com/f/devops-infrastructure/automation-orchestration/task-execution-frameworks/task-job-management/background-task-runners/thread-pool-offloading.md) — Offloads intensive computations to background threads and returns results to the main event loop using non-blocking worker patterns. ([source](https://github.com/nodejs/node-addon-api/blob/main/CHANGELOG.md))

### Software Engineering & Architecture

- [Native-to-JS Thread Dispatching](https://awesome-repositories.com/f/software-engineering-architecture/background-thread-dispatchers/thread-safe-dispatchers/ui-thread-schedulers/worker-to-ui-thread-messaging/native-to-js-thread-dispatching.md) — Invokes JavaScript functions from background threads to ensure reliable data exchange between native execution environments and the main event loop. ([source](https://github.com/nodejs/node-addon-api/blob/main/doc/README.md))
- [Native Error Code Converters](https://awesome-repositories.com/f/software-engineering-architecture/error-propagation-systems/native-error-code-converters.md) — Maps native exceptions and error states to standard JavaScript error types for consistent failure handling. ([source](https://github.com/nodejs/node-addon-api/tree/main/doc))
- [Module Lifecycle Management](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/extensibility/plugin-architectures/lifecycle-loading-frameworks/module-lifecycle-management.md) — Hooks into the module lifecycle to perform cleanup, track module data, and manage resources across multiple threads or execution contexts. ([source](https://github.com/nodejs/node-addon-api/blob/main/CHANGELOG.md))
- [Thread and Process Synchronization](https://awesome-repositories.com/f/software-engineering-architecture/process-coordinators/thread-and-process-synchronization.md) — Coordinates communication between background native threads and the main execution thread to prevent data corruption.

### Web Development

- [Native Error Reporters](https://awesome-repositories.com/f/web-development/error-handling/native-error-reporters.md) — Maps native exceptions to standard script error types to ensure consistent diagnostic reporting and stack trace propagation. ([source](https://github.com/nodejs/node-addon-api/blob/main/doc/README.md))
- [Native Panic-to-Exception Bridges](https://awesome-repositories.com/f/web-development/error-handling/native-error-reporters/native-panic-to-exception-bridges.md) — Converts internal native errors into standard script exceptions to prevent runtime crashes and provide meaningful feedback. ([source](https://github.com/nodejs/node-addon-api/blob/main/README.md))
