Search documentation

Find pages, sections, and content across all docs.

WavedashDocs

Bevy

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

View example project on GitHub Playtest the example project

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 Wavedash 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 = Wavedash)]
    fn getUser() -> JsValue;

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

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

Calling Wavedash.init() is required. Your game stays hidden behind the Wavedash loading screen until you do. Call it once your game is ready to play.

import init from "./pkg/my_game.js";
await init();
Wavedash.init({ debug: true });
Wavedash.loadComplete();

Load progress

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

Wavedash.updateLoadProgressZeroToOne(0.3); // WASM downloading
const wasm = await init();
Wavedash.updateLoadProgressZeroToOne(0.9); // initializing
wasm.start();
Wavedash.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, Wavedash exposes leaderboards, achievements, stats, and user data:

const user = Wavedash.getUser();

const lb = await Wavedash.getLeaderboard("high-scores");
await Wavedash.uploadLeaderboardScore(lb.data.id, score, true);

Wavedash.setAchievement("first_win", true);

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. Mount your canvas into a container that fills the viewport and keep asset paths relative so the build works from any subpath.