napi-rs

Build precompiled Node.js add-ons in Rust via Node-API, no node-gyp required

Framework
Cargo
v3.12.1
7,903stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
91/100Excellent
Development Activity100
Maintenance100
Community64
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture90
Code Quality88
Innovation85
Learning Curve62

napi-rs is a Rust framework for building native Node.js add-ons through Node-API (N-API), the ABI-stable interface for native modules. It replaces the traditional node-gyp toolchain with a pure Rust/JavaScript workflow: write functions annotated with the #[napi] macro from the napi-derive crate, and the napi crate handles marshalling Rust types to and from JavaScript values, async/Promise interop, threadsafe callbacks, and error propagation.

The project ships as a coordinated set of crates (napi, napi-derive, napi-sys, napi-build) plus the @napi-rs/cli npm package, which drives cross-compilation and packaging for every supported platform triple (Windows, macOS, Linux glibc/musl, Android, FreeBSD, across x64/arm64/armv7/riscv64/loongarch64). This lets library authors ship a single npm package that resolves to the correct prebuilt .node binary at install time, with no compiler required on the consumer’s machine.

What You Get

  • The #[napi] proc-macro attribute for exposing Rust functions, structs, classes, and enums directly to JavaScript with automatic type marshalling
  • First-class async support: Rust async fn becomes a JavaScript Promise, with a pluggable async-runtime SPI so a tokio-free build is possible
  • Threadsafe function support for calling back into JavaScript from any Rust thread, plus Buffer/TypedArray/BigInt/Symbol bridging
  • The @napi-rs/cli tool for building, cross-compiling, and packaging release binaries for 15+ platform triples in one command
  • A napi-build build-script helper that wires up the Node-API linking flags automatically
  • Companion packages (@napi-rs/triples, @napi-rs/wasm-runtime) for platform-triple resolution and optional WebAssembly fallback

Common Use Cases

  • Wrapping a performance-critical Rust library (parsing, cryptography, image/video processing) as a drop-in npm package for Node.js consumers
  • Building CPU-bound native modules that need true multithreading without Node’s single-threaded event loop constraints
  • Publishing cross-platform npm packages that ship prebuilt binaries instead of requiring consumers to compile from source
  • Migrating an existing node-gyp/C++ native addon to a memory-safe Rust implementation with less boilerplate

Under The Hood

Architecture - The repo is a Cargo workspace split into five crates under crates/: napi (the public runtime API — value conversion, environment handling, error types), macro (the napi-derive proc-macro crate that expands #[napi] attributes into N-API registration code at compile time), backend (shared codegen logic consumed by the macro), sys (raw napi-sys FFI bindings to the Node-API C headers), and build (the napi-build build-script helper that emits the correct linker flags). The cli directory holds the separately-versioned @napi-rs/cli npm package, written in TypeScript/Rust, which orchestrates cargo build, cross-compilation via target triples, and packaging of the resulting .node binary plus generated .d.ts files. triples and wasm-runtime are satellite npm packages for platform-triple resolution and an optional WASM fallback path. Tech Stack - Core crates target Rust edition 2021 with a workspace-pinned MSRV of 1.88.0; the async feature pulls in tokio_rt while an async-runtime feature keeps a tokio-free path available via a pluggable AsyncRuntime SPI. The JS/TS side uses Lerna for cross-package versioning and Yarn as the package manager. CI (GitHub Actions) runs an address-sanitizer workflow and a dedicated memory-leak-detection workflow (memory-testing/Cargo.toml) on every push, alongside the standard test-and-release pipeline across 15+ platform triples. Code Quality - Because native addons must run inside a Node process to resolve N-API symbols, tests live in JavaScript under test_module and exercise the compiled binary end-to-end rather than as pure Rust unit tests; this is a deliberate, documented trade-off rather than an absence of testing. The crate exposes a compat-mode feature flag specifically to preserve backward compatibility for deprecated types/traits, showing an explicit deprecation discipline. Naming is consistent throughout (napi_* for FFI, Napi* for public Rust types). API Design - The #[napi] attribute macro is the entire public surface for exposing a function, struct, class, or enum to JavaScript, and it also generates the matching .d.ts declarations automatically — getting from a plain Rust function to a callable, typed JS export requires a single attribute line and a Cargo.toml/build.rs boilerplate pair, which is a very low-friction entry point for an FFI-generation framework of this scope.

Used by 10 apps in this directory

Rust
67%
MIT

Bun

Developer Tools

95,452

An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.

View details
92
Repo Health
91
Technical
66
Dependency
Built with
Rust67%
C++19%
Updated today
C
89%
MIT

codegraph

Developer Tools · AI Code Assistants

67,011

A pre-indexed code knowledge graph that cuts AI tool calls by 58% and token costs by 16% — auto-syncing, 100% local, works with Claude Code, Cursor, Codex, and more.

View details
81
Repo Health
85
Technical
73
Dependency
Built with
C89%
Updated 1 weeks ago
TypeScript
72%
AGPL 3.0

Firecrawl

AI Development · Developer Tools

169,311

Turn any website into clean, LLM-ready data with a single API call — no proxy headaches, no scraping complexity.

View details
89
Repo Health
83
Technical
66
Dependency
Built with
TypeScript72%
Python14%
Updated today
Rust
69%
Other

GitButler

Developer Tools · Devops · AI Development

21,531

Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.

View details
89
Repo Health
84
Technical
68
Dependency
Built with
Rust69%
TypeScript18%
Svelte12%
Updated today
Rust
36%
Apache 2.0

LanceDB

Databases · AI Development

11,190

Open-source, embedded vector database built on the Lance columnar format for fast multimodal search across billions of vectors, backed by Y Combinator (W23).

View details
90
Repo Health
86
Technical
72
Dependency
Built with
Rust36%
HTML30%
Python26%
Updated today
Rust
84%
Apache 2.0

liteparse

Developer Tools

12,123

A fast, lightweight, open-source document parser that extracts spatial text, bounding boxes, and Markdown from PDFs and Office files — entirely on your machine.

View details
83
Repo Health
80
Technical
74
Dependency
Built with
Rust84%
Updated today
Rust
72%
Apache 2.0

mesh-llm

AI Development · AI Agents

3,258

Mesh LLM pools GPUs and memory across every machine you own into one OpenAI-compatible API, so agents tap distributed compute instead of a single GPU box or a metered cloud bill.

View details
83
Repo Health
91
Technical
70
Dependency
Built with
Rust72%
TypeScript16%
Updated today
Rust
72%
MIT

monty

AI Development · Developer Tools

8,079

Run LLM-generated Python code safely inside your agent—no containers, no CPython, no compromise—with sub-microsecond startup.

View details
87
Repo Health
83
Technical
73
Dependency
Built with
Rust72%
Python23%
Updated yesterday
Python
55%
Other

PostHog

Analytics · Monitoring · Developer Tools

37,777

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
67
Dependency
Built with
Python55%
TypeScript36%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search