5c47a80cfd
Signed-off-by: wangshi <wangshi@kaihong.com> |
||
---|---|---|
.. | ||
addon.md | ||
array_buffer.md | ||
array.md | ||
async_context.md | ||
async_operations.md | ||
async_worker_variants.md | ||
async_worker.md | ||
bigint.md | ||
boolean.md | ||
buffer.md | ||
callback_scope.md | ||
callbackinfo.md | ||
checker-tool.md | ||
class_property_descriptor.md | ||
cmake-js.md | ||
conversion-tool.md | ||
dataview.md | ||
date.md | ||
env.md | ||
error_handling.md | ||
error.md | ||
escapable_handle_scope.md | ||
external_buffer.md | ||
external.md | ||
function_reference.md | ||
function.md | ||
generator.md | ||
handle_scope.md | ||
hierarchy.md | ||
instance_wrap.md | ||
maybe.md | ||
memory_management.md | ||
name.md | ||
node-gyp.md | ||
number.md | ||
object_lifetime_management.md | ||
object_reference.md | ||
object_wrap.md | ||
object.md | ||
prebuild_tools.md | ||
promises.md | ||
property_descriptor.md | ||
propertylvalue.md | ||
range_error.md | ||
README.md | ||
reference.md | ||
setup.md | ||
string.md | ||
symbol.md | ||
syntax_error.md | ||
threadsafe_function.md | ||
threadsafe.md | ||
type_error.md | ||
type_taggable.md | ||
typed_array_of.md | ||
typed_array.md | ||
typed_threadsafe_function.md | ||
value.md | ||
version_management.md |
node-addon-api Documents
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. 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 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.
Setup
API Documentation
The following is the documentation for node-addon-api.
- Full Class Hierarchy
- Addon Structure
- Data Types:
- Error Handling
- Object Lifetime Management
- Memory Management
- Async Operations
- Thread-safe Functions
- Promises
- Version management
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
ABI Stability Guideline
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.
More resource and info about native Addons
There are three options for implementing addons: Node-API, nan, or direct use of internal , 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.
- 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.