Introduction

NAPI-RS is a framework for building pre-compiled Node.js addons in Rust.

Rustify Node.js in few lines!

lib.rs
use napi_derive::napi;
 
#[napi]
fn fibonacci(n: u32) -> u32 {
  match n {
    1 | 2 => 1,
    _ => fibonacci(n - 1) + fibonacci(n - 2),
  }
}

Compatible with both CommonJS and esm, with auto generated .d.ts file:

main.mjs
import { fibonacci } from './index.js'
 
// output: 5
console.log(fibonacci(5))
main.cjs
const { fibonacci } = require('./index')
 
// output: 5
console.log(fibonacci(5))

Features

🚀 Bring native performance for Node.js

👷‍♂️ Memory safe, guaranteed by Rust compiler

⚡️ Zero copy data interactive between Rust & Node.js via Buffer and TypedArray

⚙️ Parallelism in few lines

Sponsors

Platinum Sponsors Tailwind Gold Sponsors Prisma Nx Workleap Sliver Sponsors Parcel Backers

Ecosystem

AFFiNEPrisma.ioswcParcelnext.jspola.rsPolarslogseqLogseqFormat.JSastgrepperfseePerfseenpmmirrorDatabendrspackRspackHugging FacedittoTurborepo logoLoroRollup

Support matrix

Node.js

Node10Node12Node14Node16Node18Node20

Platform support

✅ Means official tested in napi-rs repo.
- Means no official Node.js release.

i686x64aarch64arm
Windows-
macOS-
Linux-
Linux musl--
FreeBSD---
Android--

Related projects