← Back to Utilities

WebAssembly (WASM) Runner

Write a Rust program, compile it with cargo build --release --target wasm32-unknown-unknown and upload the resulting *.wasm file here to call its functions with JavaScript.

See more details
  1. Create a new cargo crate with cargo init --lib folder-name.
  2. cd into the folder-name folder.
  3. Replace Cargo.toml with the below code.
  4. Put your Rust code in src/lib.rs.
  5. Below is the example Rust program used as the default .wasm file below.
  6. Your code can use the methods imported at the top of the above example.
    Note: To use the print functions, refer to the above example.
  7. Compile it using the command: cargo build --release --target wasm32-unknown-unknown
  8. Grab the file target/wasm32-unknown-unknown/release/folder-name.wasm and upload it here.
  9. If your file has a main method, it will be called automatically.
  10. Use the JavaScript editor below to run JS and call your WASM functions.
Loading wasm-test.wasm…