WavedashDocs

Bevy

Compile Bevy games to WebAssembly with Trunk or wasm-pack and wire the SDK from Rust.

View the example on GitHub

Bevy compiles to WebAssembly via wasm-bindgen and wasm-pack (or trunk). The output is a set of static files — HTML, JS, WASM, and assets — that Wavedash can host.

Build for web

Using Trunk (recommended):

trunk build --release

The output is in the dist/ folder. If using wasm-pack directly:

wasm-pack build --target web --release

Then bundle the output with an HTML shell that loads the generated JS and WASM.

SDK integration

Wavedash injects WavedashJS into the page before your WASM module loads. Call it from the JavaScript side using wasm-bindgen imports:

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(js_namespace = WavedashJS)]
    fn getUser() -> JsValue;

    #[wasm_bindgen(js_namespace = WavedashJS)]
    fn loadComplete();
}

Or keep SDK calls in JavaScript and invoke them from your HTML shell:

import init from "./pkg/my_game.js";
await init();
await WavedashJS.ready();
WavedashJS.loadComplete();

Load progress

Report progress from your JavaScript entrypoint while the WASM module downloads and initializes:

WavedashJS.updateLoadProgressZeroToOne(0.3); // WASM downloading
const wasm = await init();
WavedashJS.updateLoadProgressZeroToOne(0.9); // initializing
wasm.start();
WavedashJS.loadComplete();

wavedash.toml

game_id = "YOUR_GAME_ID_HERE"
upload_dir = "./dist"
entrypoint = "index.html"

SDK features

From the JavaScript side of your HTML shell, WavedashJS exposes leaderboards, achievements, stats, and user data:

const user = WavedashJS.getUser();

await WavedashJS.uploadLeaderboardScore("high-scores", score, true);

WavedashJS.setAchievement("first_win");
await WavedashJS.storeStats();

To call these from Rust, add corresponding wasm-bindgen externs in the SDK integration block above.

Bevy's default window size and asset paths assume a desktop environment. Make sure your index.html mounts the canvas into #wavedash-target and that asset paths are relative.