55 releases (28 stable)

Uses new Rust 2021

2.9.1 Sep 8, 2022
2.6.0 Jul 6, 2022
2.3.0-canary.0 Mar 21, 2022
2.0.4 Dec 24, 2021
0.1.0 Nov 30, 2017

#109 in Procedural macros

Download history 26628/week @ 2022-08-15 20808/week @ 2022-08-22 21377/week @ 2022-08-29 19667/week @ 2022-09-05 19575/week @ 2022-09-12 17946/week @ 2022-09-19 18911/week @ 2022-09-26 17746/week @ 2022-10-03 18973/week @ 2022-10-10 19265/week @ 2022-10-17 19460/week @ 2022-10-24 19377/week @ 2022-10-31 17908/week @ 2022-11-07 19700/week @ 2022-11-14 15303/week @ 2022-11-21 17826/week @ 2022-11-28

71,884 downloads per month
Used in 12 crates (11 directly)

MIT license

150KB
4.5K SLoC

napi-derive

chat

Checkout more examples in examples folder

#[macro_use]
extern crate napi_derive;
use napi::bindgen_prelude::*;

#[napi]
fn fibonacci(n: u32) -> u32 {
  match n {
    1 | 2 => 1,
    _ => fibonacci_native(n - 1) + fibonacci_native(n - 2),
  }
}

#[napi]
fn get_cwd<T: Fn(String) -> Result<()>>(callback: T) {
  callback(env::current_dir().unwrap().to_string_lossy().to_string()).unwrap();
}

Dependencies

~0.3–0.9MB
~21K SLoC