napi-rs Docs
NAPI-RS is a minimal library for building pre-compiled NodeJS addons in Rust.
lib.rs
#[js_function(1)]fn fibonacci(ctx: CallContext) -> Result<JsNumber> { let n = ctx.get::<JsNumber>(0)?.try_into()?; ctx.env.create_int64(fibonacci_native(n))}
index.js
function hello() { let result = fibonacci(10000) console.log(result) return result}
Features
🚀 Bring native performance for NodeJS
👷♂️ Memory safe, guaranteed by Rust
compiler
⚡️ Zero copy data interactive between Rust
& NodeJS
⚙️ Parallelism in few lines
Well tested
Support matrix
NodeJS
Node10 | Node12 | Node14 | Node15 |
---|---|---|---|
✓ | ✓ | ✓ | ✓ |
Platform support
✅ Means official tested in napi-rs repo.
-
Means no official NodeJS release.
i686 | x64 | aarch64 | arm | |
---|---|---|---|---|
Windows | ✅ | ✅ | - | - |
macOS | - | ✅ | ✅ | - |
Linux | - | ✅ | ✅ | ✅ |
Linux musl | - | ✅ | - | - |
FreeBSD | - | ✅ | - | - |
Android | - | - | ✅ | - |