Just add nodex as the dependency:
```toml [package] name = "nodex-plugin-helloworld" version = "0.1.1" edition = "2021"
[dependencies] nodex = "^0.2" ```
Then export your own function with the signature:
```rust use nodex::prelude::*;
pub fn init(env: NapiEnv, mut object: JsObject) -> NapiResult<()> { object.setnamedproperty( "helloworld", env.func(|this, ()| { let env = this.env(); let res: JsValue = env.runscript( r#" console.log("hello, nodex!"); "# )?; Ok(res) })?, )?;
Ok(())
} ```
So you can use this crate as the dependency of your nodex project:
```toml [package] name = "plugin" version = "0.1.0" edition = "2021"
[lib] crate-type = ["cdylib"]
[dependencies.nodex] features = ["v8"] version = "^0.1"
[dependencies.nodex-plugin-helloworld] version = "0.1" ```
lib.rs
```rust use nodex::prelude::*; nodex::napi_module!(init);
fn init(env: NapiEnv, exports: JsObject) -> NapiResult<()> { nodexpluginhelloworld::init(env, exports)?;
Ok(())
} ```