Huy's Notes
Compile Rust to WebAssembly

Compile Rust to WebAssembly

#rust #webassembly

A Rust program can be compiled to WebAssembly as a library or a full runnable entry point (if the project type is binary).

To compile to WebAssembly, we need to have a wasm32 compile target:

$ rustup target add wasm32-unknown-unknown

For convenience, using cargo-web seems like a widely accepted method:

$ cargo install cargo-web

And then, the actual compile and run:

$ cargo web start --target=wasm32-unknown-unknown

For exposing your data structures to WebAssembly, take a look at [wasm-bindgen].

Referred in


If you think this note resonated, be it positive or negative, please feel free to send me an email and we can talk.