Capabilities
What each capability unlocks and how to declare them.
Capabilities are how the SDK tells the platform “this game is prepared to handle X.”
Declare every capability your game uses in init(). The SDK refuses to call
gated methods if the matching capability is missing.
import { gamee } from '@gamee/sdk';
await gamee.init({
capabilities: ['saveState', 'rewardedAds', 'logEvents'],
});
The full list lives in ALL_CAPABILITIES:
import { ALL_CAPABILITIES } from '@gamee/sdk';
// → ['saveState', 'rewardedAds', 'logEvents', 'missions', 'gems']
Unknown values throw GameeError({ code: 'VALIDATION' }) at init() time.
Calling a gated method without the capability throws
GameeError({ code: 'CAPABILITY_MISSING' }) synchronously, before reaching
the wire — wrap calls in try/catch if you don’t always declare the capability.
saveState#
Persist a serialized blob between sessions. The platform stores it; your game gets
it back in init()’s response (initResponse.saveState).
Unlocks: gameSaveState(data) and the saveStateData field on gameOver().
await gamee.init({ capabilities: ['saveState'] });
// On boot, read the previous save (a string — JSON if you stringified it):
const previous = gamee.initResponse?.saveState;
if (previous) restore(JSON.parse(previous));
// During play, snapshot at any time. The SDK stringifies for you.
gamee.gameSaveState({ level: 3, gold: 120 });
// At end of run, ship the latest snapshot together with the score:
gamee.gameOver({ saveStateData: { level: 3, gold: 120 } });
rewardedAds#
Show a rewarded video and react to whether the user watched it.
Unlocks: loadRewardedVideo(), showRewardedVideo().
await gamee.init({ capabilities: ['rewardedAds'] });
// Optional: pre-warm before you offer the player the reward.
const { videoLoaded } = await gamee.loadRewardedVideo();
if (!videoLoaded) hideExtraLifeButton();
// Player tapped "watch ad for an extra life":
const { videoPlayed } = await gamee.showRewardedVideo();
if (videoPlayed) grantExtraLife();
The platform also fires the useExtraLife event after the user redeems the reward
(see events).
logEvents#
Send custom analytics events to the GAMEE platform.
Unlocks: logEvent(name) / logEvent({ name, value }).
Hard limits validated locally — exceeding either throws VALIDATION:
name: non-empty string, max 24 chars.value: string, max 160 chars.
await gamee.init({ capabilities: ['logEvents'] });
gamee.logEvent({ name: 'boss_defeated', value: JSON.stringify({ id: 'azuki', tries: 3 }) });
missions#
Used when the platform launched the game in a mission context.
Unlocks: updateMissionProgress(0..100). Also: initResponse.missionData
contains the mission config when the user opened the game from a mission card.
await gamee.init({ capabilities: ['missions'] });
if (gamee.initResponse?.gameContext === 'mission') {
const m = gamee.initResponse.missionData; // { id, value, difficulty?, ... }
configureForMission(m);
}
// During play, report progress (0–100, must be a finite number).
gamee.updateMissionProgress(42);
gems#
In-game purchase paid in GAMEE gems.
Unlocks: purchaseItemWithGems(details).
details.gemsCost must be ≥ 0; details.itemName must be a non-empty string.
await gamee.init({ capabilities: ['gems'] });
const result = await gamee.purchaseItemWithGems({
gemsCost: 50,
itemName: 'extra_life',
});
if (result.success) grantExtraLife();
Capabilities that no longer exist#
Five gamee-js capabilities did not carry over. If you used them, see the
migration guide for what to do instead.
gamee-js capability | Status |
|---|---|
replay | Removed — requestPlayerReplay and replay data are gone. |
ghostMode | Removed — ghostShow/ghostHide events are gone. |
socialData | Removed — requestSocial was deprecated in gamee-js. |
playerData | Removed — requestPlayerData is gone. |
platformExtraLife | Removed — listen for the useExtraLife event directly. |