A set of headers that make C++11 libraries accessible from JavaScript for Node.js addons and web browsers via asm.js.
nbind is a header-only library that creates bindings between C++11 code and JavaScript, enabling C++ libraries to be used as Node.js addons or in web browsers via asm.js. It solves the problem of exposing complex C++ APIs to JavaScript with minimal effort, using compile-time code generation.
C++ developers who want to expose their libraries to JavaScript environments like Node.js, Electron, or web applications without rewriting code.
Developers choose nbind for its simplicity—adding bindings requires only a few macros—and its cross-platform support, which works natively and via asm.js without changes to the original C++ code.
:sparkles: Magical headers that make your C++ library accessible from JavaScript :rocket:
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Adding bindings requires only a few macros after C++ code, as shown in the quick start with a single #include and NBIND_CLASS, eliminating extensive boilerplate.
Supports Node.js, Electron, and web browsers via asm.js on Linux, macOS, and Windows, enabling universal deployment without code changes.
Generates .d.ts files from C++ code automatically, providing IDE autocompletion and type safety in TypeScript projects, as detailed in the user guide.
Converts common types like numbers, strings, arrays, and callbacks automatically, reducing manual marshaling code, with support for custom value objects.
Callbacks passed to C++ are freed after the function returns, complicating asynchronous use and requiring manual copying for persistence, as warned in the README.
All data structures are copied between C++ and JavaScript, degrading performance for large or frequent transfers, especially in asm.js where data is copied twice.
Relies on autogypi, node-gyp, and Emscripten with Python 2.7, involving multiple dependencies and configuration steps that increase setup complexity.