87 releases (stable)

3.0.0-alpha.1 Apr 10, 2024
3.0.0-alpha.0 Mar 20, 2024
2.16.3 Apr 18, 2024
2.16.1 Mar 26, 2024
0.1.0 Nov 30, 2017

#404 in Procedural macros

Download history 85809/week @ 2023-12-23 140520/week @ 2023-12-30 165386/week @ 2024-01-06 132959/week @ 2024-01-13 120758/week @ 2024-01-20 134028/week @ 2024-01-27 136615/week @ 2024-02-03 134994/week @ 2024-02-10 110100/week @ 2024-02-17 112844/week @ 2024-02-24 116940/week @ 2024-03-02 123873/week @ 2024-03-09 127846/week @ 2024-03-16 119576/week @ 2024-03-23 122136/week @ 2024-03-30 102407/week @ 2024-04-06

493,209 downloads per month
Used in 33 crates (25 directly)

MIT license

180KB
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.9–2MB
~35K SLoC