Node-API 10 · formerly N-API
Native Node.js addons, built once, loaded everywhere.
napi-bindings is the hub for Node-API: the full API reference, versions and ecosystem, together with open-source tooling to build addons in C, C++ and Go and to run them beyond Node.js.
#include <node_api.h>
static napi_value Hello(napi_env env, napi_callback_info info) {
napi_value result;
napi_create_string_utf8(env, "world", NAPI_AUTO_LENGTH, &result);
return result;
}
static napi_value Init(napi_env env, napi_value exports) {
napi_property_descriptor desc = { "hello", 0, Hello, 0, 0, 0, napi_default, 0 };
napi_define_properties(env, exports, 1, &desc);
return exports;
}
NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)Why Node-API
Node-API is the C interface for native addons maintained by the Node.js project. It isolates addons from the JavaScript engine underneath, so a compiled binary survives engine and Node.js upgrades.
The napi-bindings projects
Tools and runtimes maintained by the napi-bindings organization. Every page is rebuilt from the repositories: README, documentation, releases and commits.