napi-rs

Create native Node.js and Bun modules using Rust with napi-rs.

15|4|Updated Jan 20, 2026
One-click install
npx skills add https://github.com/cofin/flow --skill napi-rs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: napi-rs
Source: https://github.com/cofin/flow/tree/main/skills/napi-rs
Command: npx skills add https://github.com/cofin/flow --skill napi-rs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill simplifies the process of creating high-performance native Node.js and Bun modules using Rust, enabling developers to leverage Rust's speed and safety within JavaScript environments.

Core Features & Use Cases

  • Module Setup: Configure Cargo.toml and build.rs for napi-rs.
  • Async Operations: Handle asynchronous tasks and integrate with runtimes like Tokio without blocking the JavaScript event loop.
  • ThreadsafeFunction (TSFN): Safely call JavaScript callbacks from Rust threads.
  • Data Handling: Efficiently manage Buffer and typed array data between Rust and JavaScript.
  • Error Management: Map Rust errors to JavaScript errors for a seamless developer experience.
  • Bun & Deno Integration: Embed V8/TypeScript execution using deno_core and ensure Bun compatibility.

Quick Start

Use the napi-rs skill to set up a basic Rust library for Node.js bindings.

Frequently Asked Questions about napi-rs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write native Node.js modules in Rust without blocking the event loop?

You can build native Node.js modules in Rust using napi-rs, which handles asynchronous task execution via runtimes like Tokio to prevent blocking the JavaScript event loop while executing heavy operations.

Can I call JavaScript callbacks from Rust threads when building Node native addons?

Yes, napi-rs provides ThreadsafeFunction (TSFN) patterns to safely invoke JavaScript callbacks from Rust threads, ensuring safe cross-thread communication without crashing the V8 engine.

Does napi-rs work with Bun and Deno runtimes for native module compilation?

napi-rs ensures cross-runtime compatibility, allowing you to compile native modules for Bun and integrate V8/TypeScript execution using deno_core within your Rust bindings.

How do I pass Buffer and typed array data between Rust and JavaScript?

napi-rs facilitates efficient buffer management, enabling seamless passing and manipulation of Buffer and typed array data between Rust and JavaScript environments with minimal overhead.

How do I map Rust errors to JavaScript exceptions in native Node addons?

napi-rs provides error management patterns that map Rust error types directly to JavaScript exceptions, ensuring a seamless developer experience when native Rust operations fail.

What is the best way to set up a Rust library for Node.js bindings?

The best way to set up a Rust library for Node.js bindings is configuring Cargo.toml and build.rs specifically for napi-rs, streamlining the module compilation process for your JavaScript runtime.