Publishing on Wavedash
Wavedash is a platform for publishing browser games. It hosts your game, and its SDK adds features such as player accounts, achievements, leaderboards, cloud saves and multiplayer lobbies.
This page covers projects built with the Editor, the Engine, React and Web Components. Wavedash's own PlayCanvas guide walks through an Engine project built with Vite.
Publishing Flow
To publish your game on Wavedash, follow these steps:
- Install the Wavedash CLI and create your game
- Call
Wavedash.init()when your game is ready - Build your project
- Test and upload the build
- Publish!
1. Install the Wavedash CLI and create your game
Install the CLI by following Wavedash's installation guide, then sign in:
wavedash auth login
Create your game in the Developer Portal, or from the command line with wavedash team create and wavedash project create (see the CLI commands). Make a note of the game ID, which you'll need in step 4.
2. Call Wavedash.init() when your game is ready
Wavedash shows its own loading screen until your game calls Wavedash.init(), so your game stays hidden until then. Call it once the assets your first scene needs have loaded.
When your game runs on Wavedash, the platform defines a global window.Wavedash object before your code starts, so there is nothing to install. Writing the call as window.Wavedash?.init() makes it do nothing on other hosts, so the same build still works on PlayCanvas Hosting or your own server.
- Editor
- Engine
- React
- Web Components
Create a script with the following code and attach it to an entity in your first scene, such as the Root entity:
import { Script } from 'playcanvas';
export class WavedashInit extends Script {
static scriptName = 'wavedashInit';
initialize() {
window.Wavedash?.init();
}
}
initialize() runs after the preloaded assets have loaded and the scene has been created, so your game is ready to be shown.
To show your game's loading progress on the Wavedash loading screen, forward the preload progress from a custom loading screen script:
app.on('preload:progress', (value) => {
window.Wavedash?.updateLoadProgressZeroToOne(value);
});
Call it after the assets for your first scene have loaded, for example in the callback of the AssetListLoader that loads them:
const loader = new AssetListLoader(Object.values(assets), app.assets);
loader.load(() => {
// create your scene from the loaded assets, then start the app
app.start();
window.Wavedash?.init();
});
AssetListLoader also fires a progress event for each asset it loads, so you can pass the fraction loaded so far to window.Wavedash?.updateLoadProgressZeroToOne().
Call it from an effect once the asset hooks for your first scene have finished loading:
import { useEffect } from 'react';
import { Gltf } from '@playcanvas/react';
import { useModel } from '@playcanvas/react/hooks';
export function Level() {
const { asset, loading } = useModel('level.glb');
useEffect(() => {
if (!loading) {
window.Wavedash?.init();
}
}, [loading]);
if (loading) return null;
return <Gltf asset={asset} key={asset.id} />;
}
Wait for <pc-app> to become ready, which happens once it has preloaded its assets and started, using whenReady:
<script type="module">
import { whenReady } from '@playcanvas/web-components';
const appElement = document.querySelector('pc-app');
// optional: show loading progress on the Wavedash loading screen
appElement.addEventListener('progress', (event) => {
window.Wavedash?.updateLoadProgressZeroToOne(event.loaded / event.total);
});
await whenReady(appElement);
window.Wavedash?.init();
</script>
To give window.Wavedash its types, install the @wvdsh/sdk-js package as a dev dependency and add a type-only import to the file that uses it:
import type {} from '@wvdsh/sdk-js';
Keep the import type-only. Importing the package itself throws an error whenever the game isn't running on Wavedash or in wavedash dev.
3. Build your project
- Editor
- Engine
- React
- Web Components
Download a build of your project with the Download Format set to Static Website. Extract the zip file into a folder named build, which is your upload folder.
Run your bundler's production build. If you use Vite, set its base option to './' so the build loads its files with relative paths, as Wavedash's examples do, then run npm run build. Vite writes the build to dist, which is your upload folder.
If you use Vite, set its base option to './' so the build loads its files with relative paths, as Wavedash's examples do, then run npm run build. Vite writes the build to dist, which is your upload folder.
If you use a bundler such as Vite, set its base option to './' so the build loads its files with relative paths, as Wavedash's examples do, then run npm run build. Vite writes the build to dist, which is your upload folder. Without a bundler, your upload folder is the one that contains your index.html.
4. Test and upload the build
Next to your upload folder, create a file named wavedash.toml with your game ID, and set upload_dir to the upload folder from step 3:
game_id = "YOUR_GAME_ID"
upload_dir = "./dist"
Wavedash loads index.html from the upload folder by default. Downloaded Editor builds and Vite builds both start from index.html, so no other settings are needed.
To test your game, run:
wavedash dev
This serves your build locally with the Wavedash SDK connected to test data, so you can check that your game appears and that any SDK features work.
When you're happy with it, upload the build:
wavedash build push
This prints a build ID and a playtest URL. Uploading a build doesn't make it live. You can also upload a zip file of your upload folder from the Builds tab of the Developer Portal.
5. Publish
Before you publish for the first time, fill in your game's Metadata in the Developer Portal. Wavedash lists the details it needs, such as a description, cover art and a preview video, on its publishing page.
Then publish the build using the ID from step 4:
wavedash publish BUILD_ID
You can also click Publish in the Builds tab of the Developer Portal. Your game page goes live straight away. To roll back, publish an earlier build.
Loading Files from Other Servers
Wavedash serves games cross-origin isolated. Everything in your upload folder works without changes. If your game also loads files from another server, that server must send the Cross-Origin-Resource-Policy: cross-origin and Access-Control-Allow-Origin: * headers, or the browser will block the request. This applies to CDNs, external scripts and import map entries, and any API your game calls. jsDelivr, which the Web Components Getting Started page uses, already sends both headers.
SDK Features (optional)
The global window.Wavedash object also gives your code access to the rest of the Wavedash SDK, including:
- Player accounts
- Achievements
- Leaderboards
- Cloud saves
- User-generated content
- Paid content
- Multiplayer lobbies and networking
The SDK functions reference lists every call.