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.
Member What 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
JavaScript TypeScript
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 });
import type { CrazygamesExtras } from '@filudi/game-sdk' ;
const cg : CrazygamesExtras | undefined = sdk . host . crazygames;
audio . mute (cg?. muted () ?? false );
cg?. onMuteChange ((muted : boolean ) => audio . mute (muted));
const link : string | undefined = cg?. inviteLink ({ seed : '42' });
const seed = cg?. inviteParam ( 'seed' ) ?? new URLSearchParams (location . search) . get ( 'seed' );
cg?. setGameContext ({ level : 3 });
Member What 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
JavaScript TypeScript
const url = await sdk . host . poki?. shareableURL ({ seed : '42' });
const seed = sdk . host . poki?. getURLParam ( 'seed' );
const url : string | undefined = await sdk . host . poki?. shareableURL ({ seed : '42' });
const seed : string | null | undefined = sdk . host . poki?. getURLParam ( 'seed' );
Member What it does onAudioChange(fn): OffThe platform’s audio setting changed; fn(enabled: boolean), the opposite of muted. Returns an unsubscribe
Playgama extras
JavaScript TypeScript
sdk . host . playgama?. onAudioChange ((enabled) => audio . mute ( ! enabled));
sdk . host . playgama?. onAudioChange ((enabled : boolean ) => audio . mute ( ! enabled));
One function for every host
JavaScript TypeScript
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 ();
async function shareLink (params : Record < string , string >) : Promise < string > {
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 ();
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.