Rust in the Browser

Rust cross-compiles to WebAssembly.

You'll need wasm-pack to convert your Rust into WASM and to shim it into an html file.

Once you have wasm-pack you can use cargo generate (which can be installed with cargo install cargo-generate) to create a template project:

cargo generate --git

The cd into your new project and:

wasm-pack build --target no-modules

Then, if you don't already have it, cargo install basic-http-server or use your favorite alternative to serve the files for your app:

basic-http-server -a

With wasm-pack you'll be able to create Rust packages that can be consumed and published with npm.