NAPI-RS helps you build compiled Node.js add-ons in Rust using Node-API. It supports cross-compilation and WebAssembly without relying on node-gyp.
Overview
NAPI-RS is a framework for implementing Node.js native add-ons in Rust through the stable Node-API interface. Developers define Rust functions and types that surface to JavaScript, then package per-platform binaries for loading as `.node` modules.
The toolchain includes a build CLI and Cargo integration so add-ons compile as cdylib artifacts and install with the Rust and JavaScript toolchains alone, avoiding node-gyp. Bindings cover common JavaScript values, async futures, buffers, typed arrays, and thread-safe callbacks across Node-API versions.
Platform support spans Windows, macOS, Linux variants, Android, FreeBSD, and WebAssembly targets, with documentation on packaging native binaries and optional WASI fallbacks. The project supplies templates and examples for getting started quickly.
A companion CLI copies built libraries into loadable module paths and can target custom output locations. Related crates and community packages extend the same approach for image processing and other native workloads.
Key features
- Rust-to-JavaScript bindings via Node-API
- Build without node-gyp
- Cross-platform native binary packaging
- WebAssembly and WASI support
- napi build CLI integration
- Async and thread-safe function support
- Wide Node.js runtime compatibility
- Serde and typed array interop
Use cases
- High-performance Node.js native modules
- Cross-compiled add-ons for many CPU targets
- WASM Node add-ons with image or media codecs
- Rust libraries exposed to npm packages
- CI-friendly native module builds