Back to overview

Rust & Webassembly

I barely know Rust but I like when things are easily accessible so I will try to figure out how to compile to webassembly and how to use the result. I will try to take some notes about the process here.

The following is in my opinion the best way to get started with Rust & Webassembly 🦀🕸. It avoids npm, cargo-generate, webpack and other things the tutorial throws at you.

  1. Install wasm-pack using cargo install wasm-pack
  2. Grab the no-bullshit example from wasm-bindgen
  3. Run wasm-pack build --target web to compile your Rust to Webassembly
  4. Open index.html in your browser or - for example - serve with python3 -m http.server. Unfortunately, I cannot upload an example here since it would require a supporter account.

Possibly useful links:

  1. https://rustwasm.github.io/docs/book/
  2. https://rustwasm.github.io/docs/wasm-bindgen/introduction.html#introduction
  3. https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/getting-started/manual-setup.html (I'm losing track of all the documentation for this stuff...)
  4. https://jakedeichert.com/blog/2018/01/my-experience-with-webassembly-and-rust-so-far/
  5. http://chinedufn.com/3d-webgl-basic-water-tutorial/