As part of my research on options for building the peer-to-peer Git Portal I’ve built an example which shows how to use
wasm-bindgen in a Rust WASI web app.
wasm-bindgen makes it much easier to work in the browser with Rust, but only supports the WASM not WASI Rust target, so it took a while to figure out how to do this (for the first time I believe).
I’m case any of this is useful for other Safe apps, here’s a summary of the demo from the README:
Svelte Rust/WASI in Browser Example
This example uses Rust Web Assembly compiled for WASI (the Web Assembly System Interface) running in the browser using WasmerJS, and uses
Rust is compiled for target
wasm32-wasi and bindings are generated using
wasm-bindgen plus a small amount of post-processing to adapt the bindings for WASI.
For a non-Rust example and Svelte + Wasmer/WASI template see simple-svelte-wasmer-webpack which was the starting point for this project.
- A Svelte WASM/WASI app with Rust subsystem (using target