Skip to content

host extras

Everything a game needs on every host is in the main API. sdk.host.<name> is defined only while the game runs on that host and is undefined everywhere else, so optional calls are safe. The object is the same for the life of the SDK: const { host } = sdk stays valid.

MemberWhat it does
onMuteChange(fn): OffThe portal’s mute setting changed; fn(muted: boolean). Returns an unsubscribe
muted(): booleanThe current setting
inviteLink(params): stringA link to the game with params as query, built by the portal
inviteParam(key): string | nullA parameter of the link the player arrived with
setGameContext(data): voidContext for the portal’s own features

CrazyGames extras

audio.mute(sdk.host.crazygames?.muted() ?? false);
sdk.host.crazygames?.onMuteChange((muted) => audio.mute(muted));
const link = sdk.host.crazygames?.inviteLink({ seed: '42' });
const seed = sdk.host.crazygames?.inviteParam('seed') ?? new URLSearchParams(location.search).get('seed');
sdk.host.crazygames?.setGameContext({ level: 3 });
MemberWhat it does
shareableURL(params): Promise<string>A poki.com link to the game with params
getURLParam(key): string | nullA parameter of the link the player arrived with

Poki extras

const url = await sdk.host.poki?.shareableURL({ seed: '42' });
const seed = sdk.host.poki?.getURLParam('seed');
MemberWhat it does
onAudioChange(fn): OffThe platform’s audio setting changed; fn(enabled: boolean), the opposite of muted. Returns an unsubscribe

Playgama extras

sdk.host.playgama?.onAudioChange((enabled) => audio.mute(!enabled));

One function for every host

async function shareLink(params) {
if (sdk.host.crazygames) return sdk.host.crazygames.inviteLink(params);
if (sdk.host.poki) return sdk.host.poki.shareableURL(params);
const url = new URL(location.href);
url.search = new URLSearchParams(params).toString();
return url.toString();
}

The whole object is the unavailable case: on filudi.com all three names are undefined. Mute on filudi.com is the page’s own control; a game that wants a mute button draws one.