The Wavedash SDK gives your game access to player accounts, leaderboards, achievements, multiplayer, cloud saves, and more. This page walks you through getting it set up.
How the SDK works
There's nothing to install from npm. When your game runs on Wavedash, the platform automatically makes WavedashJS available in the browser before your code starts. During local development, wavedash dev does the same thing with a sandbox version so you can test everything offline.
Methods that talk to servers are asynchronous and return Promises. Methods that read local state (like the current player) are synchronous.
View the SDK on GitHub→Initialization
The SDK loads asynchronously — you must await the init() call before using any other SDK method. It fetches configuration from the Wavedash platform and applies your settings. If you skip the await, subsequent calls will fail because the SDK isn't set up yet.
Always await WavedashJS.init(...) before using any other SDK method. This only needs to happen once — after it resolves, the SDK is ready for the rest of your session.
func _ready():
WavedashSDK.backend_connected.connect(_on_connected)
WavedashSDK.init({"debug": true, "deferEvents": true})
WavedashSDK.ready_for_events()
func _on_connected(payload):
print("SDK is ready!")
var username = WavedashSDK.get_username()
print("Playing as: ", username)
Response format
Most async SDK methods that talk to Wavedash services return a response object. Check success before using data.
const response = await WavedashJS.getLeaderboard("high-scores");
if (response.success) {
console.log(`Leaderboard: ${response.data.name}`);
} else {
console.error(`Error: ${response.message}`);
}
When a call fails, message explains what went wrong.
Error handling
Wrap async service calls in try/catch and check success:
func _on_leaderboard(response):
if not response.get("success", false):
push_error(response.get("message", "leaderboard error"))
return
var board = response["data"]
Configuration options
Pass these to init() when you need non-default behavior:
| Option | What it does |
|---|---|
debug | Turns on verbose logging in the browser console |
deferEvents | Queues lobby and multiplayer events until you call readyForEvents() |
remoteStorageOrigin | Overrides the origin for cloud file storage |
p2p | Custom P2P networking settings (see Types reference) |
If you set deferEvents: true, make sure you call readyForEvents() once your game is done loading. Otherwise queued events will never reach your handlers.
Connection events
Listen for connection changes to show online/offline status in your UI:
func _ready():
WavedashSDK.backend_connected.connect(_on_connected)
WavedashSDK.backend_disconnected.connect(_on_disconnected)
func _on_connected(payload):
print("Connected to Wavedash!")
func _on_disconnected(payload):
print("Disconnected from Wavedash")
What's next
Accounts, avatars, friends, and presence.
Lobbies, chat, and P2P networking.
Reward players for hitting milestones.
Godot, Unity, Three.js, and more.
See the Events reference for the complete event list.