Skip to content

Commit

Permalink
docs: Add some notes about cdylib
Browse files Browse the repository at this point in the history
Closes: #683
  • Loading branch information
ctron committed Jan 26, 2024
1 parent 89ce7d0 commit f42e7c2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions site/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,23 @@ include all JavaScript snippets generated by `wasm-bindgen` for interfacing with
By default, functions exported from Rust, using `wasm-bingen`, can be accessed in the JavaScript code through the global
variable `window.wasmBindings`. This behavior can be disabled, and the name can be customized.

## Library crate

Aside from having a `main` function, it is also possible to up your project as a `cdylib` project. In order to do that,
add the following to your `Cargo.toml`:

```toml
[lib]
crate-type = ["cdylib", "rlib"]
```

And then, define the entrypoint in your `lib.rs` like (does not need to be `async`):

```rust
#[wasm_bindgen(start)]
pub async fn run() {}
```

# Next Steps

That's not all! Trunk has even more useful features. Head on over to the following sections to learn more about how to use Trunk effectively.
Expand Down

0 comments on commit f42e7c2

Please sign in to comment.