@@ -78,6 +78,51 @@ it still gets the benefits of the ABI stability provided by the C API.
7878When using `node-addon-api` instead of the C APIs, start with the API [docs][]
7979for `node-addon-api`.
8080
81+ ## Rust
82+
83+ Node-API is also accessible from Rust through the [`NAPI-RS`][] project.
84+ `NAPI-RS` provides safe Rust bindings to Node-API, allowing developers to write
85+ native Node.js modules in Rust while maintaining ABI stability across Node.js
86+ versions. The project offers both low-level bindings that closely mirror the
87+ Node-API C interface and high-level, idiomatic Rust APIs that leverage Rust's
88+ type system and memory safety guarantees.
89+
90+ Similar to the C++ wrapper, `NAPI-RS` simplifies the development process.
91+ For example, creating an object with a property in `NAPI-RS`:
92+
93+ ```rust
94+ #[napi(object)]
95+ pub struct MyObject {
96+ foo: String,
97+ }
98+
99+ #[napi]
100+ pub fn create_object() -> MyObject {
101+ MyObject {
102+ foo: "bar".to_string(),
103+ }
104+ }
105+ ```
106+
107+ This will automatically generate the following TypeScript definition:
108+
109+ ```typescript
110+ export interface MyObject {
111+ foo: string;
112+ }
113+
114+ export declare function createObject(): MyObject;
115+ ```
116+
117+ The `NAPI-RS` ecosystem includes:
118+ - Build tooling that simplifies the compilation and packaging process
119+ - TypeScript type generation for better IDE support
120+ - Cross-platform compilation support, including `WebAssembly`
121+
122+ When using `NAPI-RS` for Rust-based Node.js addons, refer to the
123+ [NAPI-RS documentation](https://napi.rs) for comprehensive
124+ guides and examples.
125+
81126The [Node-API Resource](https://nodejs.github.io/node-addon-examples/) offers
82127an excellent orientation and tips for developers just getting started with
83128Node-API and `node-addon-api`. Additional media resources can be found on the
@@ -6843,6 +6888,7 @@ the add-on's file name during loading.
68436888[`napi_unwrap`]: #napi_unwrap
68446889[`napi_wrap`]: #napi_wrap
68456890[`node-addon-api`]: https://github.com/nodejs/node-addon-api
6891+ [`NAPI-RS`]: https://github.com/napi-rs/napi-rs
68466892[`node_api.h`]: https://github.com/nodejs/node/blob/HEAD/src/node_api.h
68476893[`node_api_basic_finalize`]: #node_api_basic_finalize
68486894[`node_api_create_external_string_latin1`]: #node_api_create_external_string_latin1
0 commit comments