A framework for building compiled Node.js add-ons in Rust via Node-API with zero overhead.
napi-rs is a framework for building compiled Node.js native add-ons using the Rust programming language. It provides bindings to Node-API (Node's stable native API) that allow developers to write performance-critical parts of their Node.js applications in Rust while maintaining full compatibility with JavaScript and TypeScript. The framework solves the problem of writing safe, high-performance native extensions without dealing with the complexities and memory safety issues of C/C++ add-ons.
Node.js developers who need to write performance-sensitive native extensions, Rust developers who want to integrate with Node.js ecosystems, and teams building data-intensive applications, real-time systems, or computational libraries that require native performance.
Developers choose napi-rs because it combines Rust's memory safety and performance with Node.js's ecosystem, provides zero-overhead FFI, generates TypeScript definitions automatically, and offers better developer experience compared to traditional C/C++ Node.js add-ons with fewer memory-related bugs and crashes.
A framework for building compiled Node.js add-ons in Rust via Node-API
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Direct mapping between Rust and JavaScript functions minimizes abstraction cost, enabling near-native performance without extra runtime penalties as emphasized in the README.
First-class async support allows Rust functions to return JavaScript Promises, and thread-safe calls enable execution in worker threads for better concurrency, handling I/O-bound and CPU-intensive tasks efficiently.
Automatic generation of TypeScript definitions from Rust code simplifies development and ensures type safety across the Rust-JavaScript bridge, reducing manual definition errors.
Leverages Rust's ownership model to prevent common memory issues like segfaults or leaks found in C/C++ add-ons, leading to more stable and secure native modules.
Requires proficiency in both Rust and Node-API, which can be a significant barrier for developers only familiar with JavaScript, slowing down adoption and increasing onboarding time.
Compiling native add-ons for multiple platforms adds steps to the deployment pipeline, such as managing Rust toolchains and cross-compilation, compared to pure JavaScript packages.
The ecosystem for Rust-Node.js bridges is less mature than pure JavaScript or C++ add-ons, limiting the availability of pre-built solutions and community-driven plugins or tools.