Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ajihyf/node-addon-api-helper

Repository files navigation

node-addon-api-helper

Based on node-addon-api, node-addon-api-helper(naah) provides a more convenient, type-safe and boilerplate-less way to write Node.js C++ addons.

Features:

  • Automatically transform values between JavaScript and C++
  • Automatically register exports
  • Class binding (with inheritance)
  • Custom object type
  • Thread safe function
  • Create async work and return promise
  • Can be used together with original node-addon-api, no need to rewrite all
  • Pure header, can be easily integrated

QuickStart

npm install node-addon-api node-addon-api-helper

Add following content to your GYP file.

{
'include_dirs': [
"\"require('node-addon-api').include_dir\")",
"\"require('node-addon-api-helper').include_dir\")",
]
}

naah heavily depends on C++17, if you haven't configured your project on C++17, have a look at naah.gypi as an example.

A hello world example :

#include <naah.h>

uint32_t add(uint32_t a, uint32_t b) {
return a + b;
}

NAAH_REGISTRATION {
naah::Registration::Function("add");
}

NAAH_EXPORT

Documentation

Examples

See naah directories in the fork of node-addon-examples for examples.

Thanks

About

A more convenient, type-safe and boilerplate-less way to write Node.js C++ addons.

Topics

Resources

Readme

License

MIT license

Stars

Watchers

Forks

Packages

Contributors