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

Rich Platform Support

Supports all common Node.js runtime platforms.

NAPI-RS logo NAPI-RS
Optimized Performance
Zero cost abstraction with high level features.
Support Matrix
Support Matrix
Node.js
v10 → v26All LTS & Current releases — officially tested in the napi-rs repo.
  • 10
  • 12
  • 14
  • 16
  • 18
  • 20
  • 22
  • 24
  • 26
Platform support
i686x64aarch64armriscv64s390xppc64le
Windows
macOS
Linux
Linux musl
FreeBSD
Android

Means official tested in napi-rs repo.

Means no official Node.js release.