Events

Every host event the SDK exposes, when it fires, and what to do in the handler.

The SDK exposes typed listener methods. Register them early, before ready(), so no host message is missed. The top-level sdk.on methods return nothing; sdk.achievements.onUnlocked, sdk.realtime.onRoom and sdk.realtime.onRoomError return a function that removes the listener.

Lifecycle

sdk.onPlay(callback)

The host starts play: a replay after game over, or a host-directed level start in level games. callback(data?) receives { levelIndex?: number } (1-based); a plain restart omits it. Reset the run in place.

sdk.onPlayAgain is an alias.

sdk.onToggleMute(callback)

The player toggled sound in the host chrome. callback({ isMuted }). Games must not draw their own mute button.

sdk.onGameInfo(callback)

A fresh GameInfo arrived. ready() already resolves with the first one, so most games never need this. It is where a changed safe area or content layout, or an updated player record, would show up.

Multiplayer

sdk.onGameStateUpdated(callback)

Another player pushed shared state in a turn-based challenge. callback({ id, gameState }), or callback(null) when state is cleared. Validate it and call sdk.multiplayer.actions.refuteGameState({ gameStateId: id }) if it is invalid. See Multiplayer.

sdk.realtime.onRoom(callback) and sdk.realtime.onRoomError(callback)

A realtime room became live, including one the platform joined for the player from an invite, or such a join failed. See Multiplayer.

Purchases

sdk.onPurchaseComplete(callback)

A purchase finished, whether your game started it or the player bought from the host chrome. callback({ success, item? }). Re-check ownership with sdk.hasItem. See Purchases.

Progression

sdk.achievements.onUnlocked(callback)

One or more achievements were earned, from an unlock() call or a refreshed snapshot. callback(keys), each key once. The host already shows the popup; use this for in-game celebration.

A Complete Registration

const sdk = window.RemixSDK

sdk.onPlay((data) => startRun(data?.levelIndex))
sdk.onToggleMute(({ isMuted }) => (audio.muted = isMuted))
sdk.onPurchaseComplete(() => refreshUnlocks())
sdk.achievements.onUnlocked((keys) => celebrate(keys))

await sdk.ready()