On this page

This section walks you through everything you need to begin building native Node.js addons with Node-API. It is designed for developers who are new to native addon development and want a guided path from zero to a working module.

  • Prerequisites - the C/C++ and JavaScript knowledge you need before diving in
  • The tools you'll need - how to install Node, npm, Git, and the C/C++ toolchain on Windows, macOS, and Linux
  • Anatomy of a Node-API project - the common directory layout, package.json entries, binding.gyp, and the JavaScript wrapper layer shared by every node-addon-api project
  • Your first project - building and running your first Node-API module
  • ObjectWrap - exposing C++ objects as JavaScript objects using node-addon-api's ObjectWrap class
  • Migrating from NAN - converting an existing NAN-based addon to Node-API

Node-API operates at two levels:

  • C API - built directly into Node.js and documented on the Node.js API pages. Gives you maximum control and no extra dependencies.
  • C++ wrapper (node-addon-api) - an npm package that wraps the C API in a friendlier C++ object model. Recommended for most projects because it reduces boilerplate significantly while preserving full ABI stability.

The examples in this section use node-addon-api.