Node.js N-API for Rust
summary
Describes using Node.js N-API (the stable C ABI) to write native addons in Rust without tying them to V8, with bindgen and procedural macros generating safe Rust wrappers for raw N-API calls. Shows sharing memory between JS and Rust via ArrayBuffer/TypedArray, using rayon parallel iterators in Rust to compute sum-of-squares, reports a 17× speedup compared to JS, and gives examples that compile with node-gyp or in a Docker development container and run end-to-end.
AI-written summary · about
chapters (20)
- 0:00Introduction
- 1:03Native addon issues
- 3:17N-API benefits
- 5:43N-API bridge for Rust
- 8:10N-API low-level improvements
- 10:40Building addons with node-gyp
- 12:31Basic N-API addon demo
- 17:12Error handling in N-API
- 22:38Rust headers with napi-rs
- 26:00Wrapping Rust code
- 27:44Type-safe N-API abstractions
- 33:21Macros for simpler code
- 39:02Module entry point
- 41:22Build and test Rust addon
- 43:18Argument validation
- 45:55Multithreaded demo
- 46:39Rust for compute tasks
- 51:27Rust vs JavaScript performance
- 53:15Parallel computing with Rust
- 54:11Conclusion & Q&A
related talks
29mRust Native Module with Node-API
28mN-API - The new native in node.js
31mN-API: The Next Generation Node.js API is Ready!
26mN-API - next generation Node API for native modules
29mN-API on JerryScript
30mRust in the Browser for Javascripters:New Frontiers,New Possibilities
39mNext Generation N-API: A Hands-on Workshop
30mPumping up Node js modules with Rust!
