Sign inDemoInstall


Package Overview
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies


Comparing version 7.1.0 to 8.0.0



@@ -478,7 +478,7 @@ {

"pre-commit": "lint",
"version": "7.1.0",
"version": "8.0.0",
"support": true,
"engines": {
"node": "^16 || ^18 || >= 20"
"node": "^18 || ^20 || >= 21"

@@ -1,13 +0,5 @@

NOTE: The default branch has been renamed!
master is now named main
# **node-addon-api module**
If you have a local clone, you can update it by running:
[![NPM](]( [![NPM](](
git branch -m master main
git fetch origin
git branch -u origin/main main
# **node-addon-api module**
This module contains **header-only C++ wrapper classes** which simplify

@@ -18,65 +10,15 @@ the use of the C based [Node-API](

There are three options for implementing addons: Node-API, nan, or direct
use of internal V8, libuv, and Node.js libraries. Unless there is a need for
direct access to functionality that is not exposed by Node-API as outlined
in [C/C++ addons](
in Node.js core, use Node-API. Refer to
[C/C++ addons with Node-API](
for more information on Node-API.
- [API References](doc/
- [Badges](#badges)
- [Contributing](#contributing)
- [License](#license)
Node-API is an ABI stable C interface provided by Node.js for building native
addons. It is independent of the underlying JavaScript runtime (e.g. V8 or ChakraCore)
and is maintained as part of Node.js itself. It is intended to insulate
native addons from changes in the underlying JavaScript engine and allow
modules compiled for one version to run on later versions of Node.js without
## API References
The `node-addon-api` module, which is not part of Node.js, preserves the benefits
of the Node-API as it consists only of inline code that depends only on the stable API
provided by Node-API. As such, modules built against one version of Node.js
using node-addon-api should run without having to be rebuilt with newer versions
of Node.js.
API references are available in the [doc](doc/ directory.
It is important to remember that *other* Node.js interfaces such as
`libuv` (included in a project via `#include <uv.h>`) are not ABI-stable across
Node.js major versions. Thus, an addon must use Node-API and/or `node-addon-api`
exclusively and build against a version of Node.js that includes an
implementation of Node-API (meaning an active LTS version of Node.js) in
order to benefit from ABI stability across Node.js major versions. Node.js
provides an [ABI stability guide][] containing a detailed explanation of ABI
stability in general, and the Node-API ABI stability guarantee in particular.
## Current version: 8.0.0
As new APIs are added to Node-API, node-addon-api must be updated to provide
wrappers for those new APIs. For this reason, node-addon-api provides
methods that allow callers to obtain the underlying Node-API handles so
direct calls to Node-API and the use of the objects/methods provided by
node-addon-api can be used together. For example, in order to be able
to use an API for which the node-addon-api does not yet provide a wrapper.
APIs exposed by node-addon-api are generally used to create and
manipulate JavaScript values. Concepts and operations generally map
to ideas specified in the **ECMA262 Language Specification**.
The [Node-API Resource]( offers an
excellent orientation and tips for developers just getting started with Node-API
and node-addon-api.
- **[Setup](#setup)**
- **[API Documentation](#api)**
- **[Examples](#examples)**
- **[Tests](#tests)**
- **[More resource and info about native Addons](#resources)**
- **[Badges](#badges)**
- **[Code of Conduct](**
- **[Contributors](#contributors)**
- **[License](#license)**
## **Current version: 7.1.0**
(See []( for complete Changelog)
[![NPM](]( [![NPM](](
<a name="setup"></a>
node-addon-api is based on [Node-API]( and supports using different Node-API versions.

@@ -87,181 +29,6 @@ This allows addons built with it to run with Node.js versions which support the targeted Node-API version.

The oldest Node.js version supported by the current version of node-addon-api is Node.js 16.x.
The oldest Node.js version supported by the current version of node-addon-api is Node.js 18.x.
## Setup
- [Installation and usage](doc/
- [node-gyp](doc/
- [cmake-js](doc/
- [Conversion tool](doc/
- [Checker tool](doc/
- [Generator](doc/
- [Prebuild tools](doc/
## Badges
<a name="api"></a>
### **API Documentation**
The following is the documentation for node-addon-api.
- [Full Class Hierarchy](doc/
- [Addon Structure](doc/
- Data Types:
- [Env](doc/
- [CallbackInfo](doc/
- [Reference](doc/
- [Value](doc/
- [Name](doc/
- [Symbol](doc/
- [String](doc/
- [Number](doc/
- [Date](doc/
- [BigInt](doc/
- [Boolean](doc/
- [External](doc/
- [Object](doc/
- [Array](doc/
- [ObjectReference](doc/
- [PropertyDescriptor](doc/
- [Function](doc/
- [FunctionReference](doc/
- [ObjectWrap](doc/
- [ClassPropertyDescriptor](doc/
- [Buffer](doc/
- [ArrayBuffer](doc/
- [TypedArray](doc/
- [TypedArrayOf](doc/
- [DataView](doc/
- [Error Handling](doc/
- [Error](doc/
- [TypeError](doc/
- [RangeError](doc/
- [SyntaxError](doc/
- [Object Lifetime Management](doc/
- [HandleScope](doc/
- [EscapableHandleScope](doc/
- [Memory Management](doc/
- [Async Operations](doc/
- [AsyncWorker](doc/
- [AsyncContext](doc/
- [AsyncWorker Variants](doc/
- [Thread-safe Functions](doc/
- [ThreadSafeFunction](doc/
- [TypedThreadSafeFunction](doc/
- [Promises](doc/
- [Version management](doc/
<a name="examples"></a>
### **Examples**
Are you new to **node-addon-api**? Take a look at our **[examples](**
- **[Hello World](**
- **[Pass arguments to a function](**
- **[Callbacks](**
- **[Object factory](**
- **[Function factory](**
- **[Wrapping C++ Object](**
- **[Factory of wrapped object](**
- **[Passing wrapped object around](**
<a name="tests"></a>
### **Tests**
To run the **node-addon-api** tests do:
npm install
npm test
To avoid testing the deprecated portions of the API run
npm install
npm test --disable-deprecated
To run the tests targeting a specific version of Node-API run
npm install
npm test --NAPI_VERSION=X
where X is the version of Node-API you want to target.
To run a specific unit test, filter conditions are available
compile and run only tests on and objectwrap.js
npm run unit --filter=objectwrap
Multiple unit tests cane be selected with wildcards
compile and run all test files ending with "reference" ->,,
npm run unit --filter=*reference
Multiple filter conditions can be joined to broaden the test selection
compile and run all tests under folders threadsafe_function and typed_threadsafe_function and also the file
npm run unit --filter='*function objectwrap'
### **Debug**
To run the **node-addon-api** tests with `--debug` option:
npm run-script dev
If you want a faster build, you might use the following option:
npm run-script dev:incremental
Take a look and get inspired by our **[test suite](**
### **Benchmarks**
You can run the available benchmarks using the following command:
npm run-script benchmark
See [benchmark/](benchmark/ for more details about running and adding benchmarks.
<a name="resources"></a>
### **More resource and info about native Addons**
- **[C++ Addons](**
- **[Node-API](**
- **[Node-API - Next Generation Node API for Native Modules](**
- **[How We Migrated Realm JavaScript From NAN to Node-API](**
As node-addon-api's core mission is to expose the plain C Node-API as C++
wrappers, tools that facilitate n-api/node-addon-api providing more
convenient patterns for developing a Node.js add-on with n-api/node-addon-api
can be published to NPM as standalone packages. It is also recommended to tag
such packages with `node-addon-api` to provide more visibility to the community.
Quick links to NPM searches: [keywords:node-addon-api](
<a name="other-bindings"></a>
### **Other bindings**
- **[napi-rs](** - (`Rust`)
<a name="badges"></a>
### **Badges**
The use of badges is recommended to indicate the minimum version of Node-API

@@ -284,3 +51,3 @@ required for the module. This helps to determine which Node.js major versions are

## **Contributing**
## Contributing

@@ -290,7 +57,6 @@ We love contributions from the community to **node-addon-api**!

<a name="contributors"></a>
## Team members
### Active
| Name | GitHub Link |

@@ -306,3 +72,8 @@ | ------------------- | ----------------------------------------------------- |

### Emeritus
| Name | GitHub Link |

@@ -319,7 +90,8 @@ | ------------------- | ----------------------------------------------------- |

<a name="license"></a>
## License
Licensed under [MIT](./
[ABI stability guide]:
[Node-API support matrix]:
SocketSocket SOC 2 Logo


  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc