Introduction

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

Rustify Node.js in few lines!

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:

import { fibonacci } from './index.js'

// output: 5
console.log(fibonacci(5))
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

⚙️ Parallelism in few lines

Well tested

LintLinux muslmacOS/Windows/Linux x64Linux-aarch64Linux-armv7macOS-AndroidAndroid-armv7Windows i686Windows arm64FreeBSD

Sponsors

Platinum SponsorsGold Sponsors Prisma GitHub Sliver Sponsors Durran Backers

Ecosystem

Prisma.ioswcParcelnext.js

Support matrix

Node.js

Node10Node12Node14Node16Node18

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