How to Build a Frontend Application with Yew (Rust WASM Framework)

Web
Build a Yew frontend by initializing a Cargo project, adding the yew dependency, and running trunk serve to compile and host the app.

You build a Yew frontend by creating a new Cargo project with the wasm32-unknown-unknown target, adding the yew dependency, and compiling with trunk or wasm-pack.

cargo new my-yew-app --lib
cd my-yew-app
cargo add yew wasm-bindgen
cargo install trunk
trunk serve --open
  1. Create a new library project and navigate into it.
  2. Add the yew and wasm-bindgen dependencies to your Cargo.toml.
  3. Install the trunk build tool globally via Cargo.
  4. Run trunk serve to compile your Rust code to WebAssembly and start a local development server.