webassembly-component-development
Installation
SKILL.md
WebAssembly Component Development
Build components against WASI 0.3 (wasip3). It adds native async, stream<T> and future<T> to the component model, so most of the old workarounds (poll loops, tokio_unstable, third-party async runtimes) are no longer needed for new code. Fall back to wasip2 only when a runtime or dependency requires it.
Key Defaults
- Target:
wasm32-wasip3(Tier 2 in Rust, stable since 1.100.0). Use thewasip3crate for WASI bindings (wasip2crate for the fallback). Gate code with#[cfg(all(target_os = "wasi", target_env = "p3"))]. - Build: use
wash buildwhen the project has.wash/config.yaml. For plugins usewash build --skip-fetch(thewasmcloud:washinterface isn't published). Otherwisecargo build --target wasm32-wasip3 --release. - Async: use the component model's native async:
async fnin exported handlers,wit_stream/wit_futurefor streams and futures,wit_bindgen::spawn_localfor background tasks. Don't pull intokioorwstdfor new p3 code (see async.md). - Threading: not available yet.
std::thread::spawnreturns an error on wasip3, and cooperative threading is still in development. Design single-threaded and avoidrayon. - Strings: UTF-8. Avoid
as_encoded_bytes(). - Version matching: the runtime must implement the exact WASI 0.3.x versions your component imports. Check with
wasm-tools component wit component.wasm. - wasmCloud docs: use https://wasmcloud.com/docs/, never
/docs/v1/.
Reference Files
Load the relevant file when working on the matching topic: