Skip to content
Module for using N-API from C++
C++ JavaScript C Python
Branch: master
Clone or download
tniessen and gabrielschulhof Disable caching in ArrayBuffer
Caching the data pointer and the byteLength in the ArrayBuffer class
causes it to behave incorrectly when the buffer is detached.

PR-URL: #611
Reviewed-By: Nicola Del Gobbo <>
Reviewed-By: Michael Dawson <>
Latest commit b72f1d6 Nov 28, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
benchmark add benchmarking framework Dec 14, 2019
doc Add Env::RunScript Dec 14, 2019
external-napi Include-path-juggle node_api.h instead of napi.h (#41) (#42) May 23, 2017
src src: make 'nothing' target a static library Sep 28, 2018
test Disable caching in ArrayBuffer Dec 14, 2019
tools objectwrap: add template methods Dec 5, 2019
.editorconfig Conditional support for C++ exceptions (#52) Jun 9, 2017
.gitignore Set up unit tests (#24) Apr 18, 2017
.npmignore Prepare for publish to npm (#33) May 4, 2017
.npmrc build: avoid using package-lock.json Oct 22, 2018
.travis.yml test: improve guards for experimental features Nov 1, 2019 Prepare release 2.0.0 Nov 21, 2019 Fix Code of conduct link properly (#323) Sep 5, 2018 Update repo name May 18, 2017 add benchmarking framework Dec 14, 2019
appveyor.yml fix test files Jun 14, 2018
common.gypi add benchmarking framework Dec 14, 2019
except.gypi add benchmarking framework Dec 14, 2019
index.js src: fix selection logic for 6.x Nov 28, 2018
napi-inl.deprecated.h src: fix missing void*data usage in PropertyDescriptors Dec 28, 2018
napi-inl.h Disable caching in ArrayBuffer Dec 14, 2019
napi.h Disable caching in ArrayBuffer Dec 14, 2019
noexcept.gypi add benchmarking framework Dec 14, 2019
package.json add benchmarking framework Dec 14, 2019

node-addon-api module

This module contains header-only C++ wrapper classes which simplify the use of the C based N-API provided by Node.js when using C++. It provides a C++ object model and exception handling semantics with low overhead.

N-API is an ABI stable C interface provided by Node.js for building native addons. It is independent from 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 recompilation.

The node-addon-api module, which is not part of Node.js, preserves the benefits of the N-API as it consists only of inline code that depends only on the stable API provided by N-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.

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 N-API and/or node-addon-api exclusively and build against a version of Node.js that includes an implementation of N-API (meaning a version of Node.js newer than 6.14.2) 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 N-API ABI stability guarantee in particular.

As new APIs are added to N-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 N-API handles so direct calls to N-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.

Current version: 2.0.0

(See for complete Changelog)



API Documentation

The following is the documentation for node-addon-api.


Are you new to node-addon-api? Take a look at our examples


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 node-addon-api tests with --debug option:

npm run-script dev

If you want faster build, you might use the following option:

npm run-script dev:incremental

Take a look and get inspired by our test suite


You can run the available benchmarks using the following command:

npm run-script benchmark

See benchmark/ for more details about running and adding benchmarks.


We love contributions from the community to node-addon-api. See for more details on our philosophy around extending this module.

More resource and info about native Addons

Team members


Name GitHub Link
Anna Henningsen addaleax
Gabriel Schulhof gabrielschulhof
Hitesh Kanwathirtha digitalinfinity
Jim Schlight jschlight
Michael Dawson mhdawson
Kevin Eady KevinEady
Nicola Del Gobbo NickNaso


Name GitHub Link
Arunesh Chandra aruneshchandra
Benjamin Byholm kkoopa
Jason Ginchereau jasongin
Sampson Gao sampsongao
Taylor Woll boingoing

Licensed under MIT

You can’t perform that action at this time.