Your local development environment will need a couple of tools to compile, build, package and debug your Yew application.
To install Rust follow the official instructions.
The minimum supported Rust version (MSRV) for Yew is
1.45.0. Older versions can cause unexpected issues accompanied by incomprehensible error messages.
You can check your toolchain version using
rustup show (under "active toolchain") or alternatively
rustc --version. To update your toolchain, run
Install WebAssembly target
Rust can compile source codes for different "targets" (e.g. different processors). The compilation target for browser-based WebAssembly is called "wasm32-unknown-unknown". The following command will add this target to your development environment.
rustup target add wasm32-unknown-unknown
Trunk is the recommended tool for managing deployment and packaging, and will be used throughout the documentation and examples. See Wasm Build Tools for more information on packaging and alternatives.
note that this might take a while to install, because it compiles everything from scratch
Trunk also provides prebuilt binaries for a number of major package managers
https://trunkrs.dev/#install for further detailsSee
cargo install trunk ```
Trunk uses a tool called wasm-bindgen-cli to perform deployment and packaging, which should be installed using the following command.
Now that you have all the tools needed, we can build a sample application.