[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-5556":3},{"id":4,"name":5,"fullName":6,"owner":5,"repo":5,"description":7,"homepage":8,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":15,"forks30d":15,"starsTrendScore":19,"compositeScore":20,"rankGlobal":9,"rankLanguage":9,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":24,"topics":25,"createdAt":9,"pushedAt":9,"updatedAt":32,"readmeContent":33,"aiSummary":34,"trendingCount":15,"starSnapshotCount":15,"syncStatus":35,"lastSyncTime":36,"discoverSource":37},5556,"napi-rs","napi-rs\u002Fnapi-rs","A framework for building compiled Node.js add-ons in Rust via Node-API","https:\u002F\u002Fnapi.rs",null,"Rust",7780,386,30,229,0,1,8,52,3,38.76,"Other",false,"main",true,[26,27,5,28,29,30,31],"javascript","napi","node","node-api","nodejs","rust","2026-06-12 02:01:12","# napi-rs\n\n> This project was initialized from [xray](https:\u002F\u002Fgithub.com\u002Fatom\u002Fxray)\n\nA framework for building compiled `Node.js` add-ons in `Rust` via Node-API. Website: https:\u002F\u002Fnapi.rs\n\n\u003Cp>\n  \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002FSpWzYHsKHs\">\n  \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fdiscord\u002F874290842444111882.svg?logo=discord&style=flat-square\"\n      alt=\"chat\" \u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fdocs.rs\u002Fcrate\u002Fnapi\">\u003Cimg src=\"https:\u002F\u002Fdocs.rs\u002Fnapi\u002Fbadge.svg\">\u003C\u002Fimg>\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fcrates.io\u002Fcrates\u002Fnapi\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fcrates\u002Fv\u002Fnapi.svg\">\u003C\u002Fimg>\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@napi-rs\u002Fcli\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fv\u002F@napi-rs\u002Fcli.svg\">\u003C\u002Fimg>\u003C\u002Fa>\n\u003C\u002Fp>\n\n## Sponsors\n\n![](https:\u002F\u002Fsponsors.napi.rs\u002Fsponsors.svg)\n\n## Platform Support\n\n[![Test & Release](https:\u002F\u002Fgithub.com\u002Fnapi-rs\u002Fnapi-rs\u002Factions\u002Fworkflows\u002Ftest-release.yaml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fnapi-rs\u002Fnapi-rs\u002Factions\u002Fworkflows\u002Ftest-release.yaml)\n[![Address Sanitizer](https:\u002F\u002Fgithub.com\u002Fnapi-rs\u002Fnapi-rs\u002Factions\u002Fworkflows\u002Fasan.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fnapi-rs\u002Fnapi-rs\u002Factions\u002Fworkflows\u002Fasan.yml)\n[![Memory Leak Detect](https:\u002F\u002Fgithub.com\u002Fnapi-rs\u002Fnapi-rs\u002Factions\u002Fworkflows\u002Fmemory-test.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fnapi-rs\u002Fnapi-rs\u002Factions\u002Fworkflows\u002Fmemory-test.yml)\n\n## MSRV\n\n**Rust** `1.88.0`\n\n|                       | node12 | node14 | node16 | node18 | node20 | node22 |\n| --------------------- | ------ | ------ | ------ | ------ | ------ | ------ |\n| Windows x64           | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| Windows x86           | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| Windows arm64         | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| macOS x64             | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| macOS aarch64         | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| Linux x64 gnu         | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| Linux x64 musl        | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| Linux aarch64 gnu     | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| Linux aarch64 musl    | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| Linux arm gnueabihf   | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| Linux arm muslebihf   | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| Linux powerpc64le gnu | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| Linux s390x gnu       | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| Linux loong64 gnu     | N\u002FA    | N\u002FA    | N\u002FA    | ✓      | ✓      | ✓      |\n| Linux riscv64 gnu     | N\u002FA    | N\u002FA    | ✓      | ✓      | ✓      | ✓      |\n| Linux aarch64 android | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| Linux armv7 android   | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n| FreeBSD x64           | ✓      | ✓      | ✓      | ✓      | ✓      | ✓      |\n\nThis library depends on Node-API and requires `Node@10.0.0` or later.\n\nWe already have some packages written by `napi-rs`: [node-rs](https:\u002F\u002Fgithub.com\u002Fnapi-rs\u002Fnode-rs)\n\nOne nice feature is that this crate allows you to build add-ons purely with the `Rust\u002FJavaScript` toolchain and without involving `node-gyp`.\n\n## Taste\n\n> You can start from [package-template](https:\u002F\u002Fgithub.com\u002Fnapi-rs\u002Fpackage-template) to play with `napi-rs`\n\n### Define JavaScript functions\n\n```rust\nuse napi::bindgen_prelude::*;\nuse napi_derive::napi;\n\n\u002F\u002F\u002F module registration is done by the runtime, no need to explicitly do it now.\n#[napi]\npub fn fibonacci(n: u32) -> u32 {\n  match n {\n    1 | 2 => 1,\n    _ => fibonacci(n - 1) + fibonacci(n - 2),\n  }\n}\n\n\u002F\u002F\u002F use `Fn`, `FnMut` or `FnOnce` traits to defined JavaScript callbacks\n\u002F\u002F\u002F the return type of callbacks can only be `Result`.\n#[napi]\npub fn get_cwd\u003CT: Fn(String) -> Result\u003C()>>(callback: T) {\n  callback(\n    std::env::current_dir()\n      .unwrap()\n      .to_string_lossy()\n      .to_string(),\n  )\n  .unwrap();\n}\n\n\u002F\u002F\u002F or, define the callback signature in where clause\n#[napi]\npub fn test_callback\u003CT>(callback: T) -> Result\u003C()>\nwhere\n  T: Fn(String) -> Result\u003C()>,\n{\n  callback(std::env::current_dir()?.to_string_lossy().to_string())\n}\n\n\u002F\u002F\u002F async fn, require `async` feature enabled.\n\u002F\u002F\u002F [dependencies]\n\u002F\u002F\u002F napi = {version=\"2\", features=[\"async\"]}\n#[napi]\npub async fn read_file_async(path: String) -> Result\u003CBuffer> {\n  Ok(tokio::fs::read(path).await?.into())\n}\n```\n\nmore examples at [examples](.\u002Fexamples\u002Fnapi)\n\n## Building\n\nThis repository is a `Cargo` crate. Any napi-based add-on should contain `Cargo.toml` to make it a Cargo crate.\n\nIn your `Cargo.toml` you need to set the `crate-type` to `\"cdylib\"` so that cargo builds a C-style shared library that can be dynamically loaded by the Node executable. You'll also need to add this crate as a dependency.\n\n```toml\n[package]\nname = \"awesome\"\n\n[lib]\ncrate-type = [\"cdylib\"]\n\n[dependencies]\nnapi = \"3\"\nnapi-derive = \"3\"\n\n[build-dependencies]\nnapi-build = \"1\"\n```\n\nAnd create `build.rs` in your own project:\n\n```rust\n\u002F\u002F build.rs\nextern crate napi_build;\n\nfn main() {\n  napi_build::setup();\n}\n```\n\nSo far, the `napi` build script has only been tested on `macOS` `Linux` `Windows x64 MSVC` and `FreeBSD`.\n\nInstall the `@napi-rs\u002Fcli` to help you build your `Rust` codes and copy `Dynamic lib` file to `.node` file in case you can `require` it in your program.\n\n```js\n{\n  \"package\": \"awesome-package\",\n  \"devDependencies\": {\n    \"@napi-rs\u002Fcli\": \"^1.0.0\"\n  },\n  \"napi\": {\n    \"name\": \"jarvis\" \u002F\u002F \u003C----------- Config the name of native addon, or the napi command will use the name of `Cargo.toml` for the binary file name.\n  },\n  \"scripts\": {\n    \"build\": \"napi build --release\",\n    \"build:debug\": \"napi build\"\n  }\n}\n```\n\nThen you can require your native binding:\n\n```js\nrequire('.\u002Fjarvis.node')\n```\n\nThe `module_name` would be your `package` name in your `Cargo.toml`.\n\n`xxx => .\u002Fxxx.node`\n\n`xxx-yyy => .\u002Fxxx_yyy.node`\n\nYou can also copy `Dynamic lib` file to an appointed location:\n\n```bash\nnapi build [--release] .\u002Fdll\nnapi build [--release] .\u002Fartifacts\n```\n\nThere are [documents](.\u002Fcli) which contains more details about the `@napi-rs\u002Fcli` usage.\n\n## Testing\n\nBecause libraries that depend on this crate must be loaded into a Node executable in order to resolve symbols, all tests are written in JavaScript in the `test_module` subdirectory.\n\nTo run tests:\n\n```sh\nyarn build:test\nyarn test\n```\n\n## Related projects\n\n- [neon](https:\u002F\u002Fwww.neon-bindings.com)\n- [node-bindgen](https:\u002F\u002Fgithub.com\u002Finfinyon\u002Fnode-bindgen)\n\n## Features table\n\n| Rust Type                | Node Type           | [NAPI Version](https:\u002F\u002Fnodejs.org\u002Fapi\u002Fn-api.html#n_api_node_api_version_matrix) | Minimal Node version | Enable by `napi` feature |\n| ------------------------ | ------------------- | ------------------------------------------------------------------------------- | -------------------- | ------------------------ |\n| u32                      | Number              | 1                                                                               | v8.0.0               |\n| i32\u002Fi64                  | Number              | 1                                                                               | v8.0.0               |\n| f64                      | Number              | 1                                                                               | v8.0.0               |\n| bool                     | Boolean             | 1                                                                               | v8.0.0               |\n| String\u002F&'a str           | String              | 1                                                                               | v8.0.0               |\n| Latin1String             | String              | 1                                                                               | v8.0.0               | latin1                   |\n| UTF16String              | String              | 1                                                                               | v8.0.0               |\n| Object                   | Object              | 1                                                                               | v8.0.0               |\n| serde_json::Map          | Object              | 1                                                                               | v8.0.0               | serde-json               |\n| serde_json::Value        | any                 | 1                                                                               | v8.0.0               | serde-json               |\n| Array                    | Array\u003Cany>          | 1                                                                               | v8.0.0               |\n| Vec\u003CT>                   | Array\u003CT>            | 1                                                                               | v8.0.0               |\n| Buffer                   | Buffer              | 1                                                                               | v8.0.0               |\n| External\u003CT>              | External\u003CT>         | 1                                                                               | v8.0.0               |                          |\n| Null                     | null                | 1                                                                               | v8.0.0               |\n| Undefined\u002F()             | undefined           | 1                                                                               | v8.0.0               |\n| Result\u003C()>               | Error               | 1                                                                               | v8.0.0               |\n| T: Fn(...) -> Result\u003CT>  | Function            | 1                                                                               | v8.0.0               |\n| Async\u002FFuture             | Promise\u003CT>          | 4                                                                               | v10.6.0              | async                    |\n| AsyncTask                | Promise\u003CT>          | 1                                                                               | v8.5.0               |\n| JsGlobal                 | global              | 1                                                                               | v8.0.0               |\n| JsSymbol                 | Symbol              | 1                                                                               | v8.0.0               |\n| Int8Array\u002FUint8Array ... | TypedArray          | 1                                                                               | v8.0.0               |\n| JsFunction               | threadsafe function | 4                                                                               | v10.6.0              | napi4                    |\n| BigInt                   | BigInt              | 6                                                                               | v10.7.0              | napi6                    |\n","napi-rs 是一个用于通过 Node-API 以 Rust 语言构建编译型 Node.js 插件的框架。它允许开发者利用 Rust 的高性能和安全性来开发 Node.js 扩展，同时保持与 JavaScript 的无缝集成。项目支持广泛的平台和 Node.js 版本，并且提供了详尽的文档和社区支持。适用于需要在 Node.js 应用中嵌入高性能计算或对安全性有高要求的场景。",2,"2026-06-11 03:03:56","top_language"]