Skip to content

Building pre-compiled
Node.js addons in Rust

Seamless WebAssembly integration, safer API designs with lifetime management, and simplified cross-compilation for broader platform support.

Live WASM + NAPI-RS Demo

This is a sample app using NAPI-RS WebAssembly. You can transform the image to webp, jpeg or avif with different quality.

Transform Image App
TS Code
import { Transformer } from '@napi-rs/image'

export async function transform() {
  const imageResponse = await fetch(
    'https://upload.wikimedia.org/wikipedia/commons/5/5d/ISS-45_EVA-2_%28a%29_Scott_Kelly.jpg'
  )

  const imageBytes = await imageResponse.arrayBuffer()

  const transformer = new Transformer(imageBytes)
  const webp = await transformer.toWebp()
}
Rust Code
use napi::bindgen_prelude::*;
use napi_derive::napi;

#[napi]
pub struct Transformer {
  inner: Uint8Array,
}

#[napi]
impl Transformer {
  #[napi(constructor)]
  pub fn new(inner: Uint8Array) -> Self {
    Self { inner }
  }

  #[napi]
  pub fn to_webp(&self) -> Result<Uint8Array> {
    let image = image::load_from_memory(&self.inner)?;
    let webp = image.to_webp().map_err(|e| Error::from(e.to_string()))?;
    Ok(webp.into())
  }
}

Feature Highlights

> napi build
Finished `release` profile [optimized] target(s)

Zero-Config Build (napi build)

Simple build command, no file copy or hand writing js binding needed.

Powerful & Flexible CI

Reduce the complex CI setup, stay focus on your development.

Apple
Node
Linux
Chrome
ubuntu

Portable Native Packages

Package per-target native binaries with an optional WASI fallback.

NAPI-RS logo NAPI-RS
Optimized Performance
Low-overhead generated bindings with high-level features.
Support Matrix
Support Matrix
Runtime compatibility
Node-API ABI stabilityOne binary can span compatible Node.js releases. The Node-API level sets the actual runtime floor.

Current napi-rs source CI:

  • Node 22
  • Node 24
  • Node 26

Use Node.js 22.13+ or 24+ for the current build CLI. Bun is best-effort in upstream CI; Deno is not in the blocking native-addon matrix.

Read the complete support contract →
Generated template build targets
ia32x64arm64armWASI
Windows MSVC
macOS
Linux glibc
Linux musl
FreeBSD
Android
WebAssembly

Included in the maintained scaffold's build/package matrix.

Not included in the maintained scaffold; it may require manual support or may be unavailable.

Accepted targets and test coverage →