About poki-js-sdk
poki-js-sdk is a skill for adding the Poki JavaScript SDK to games. It guides developers through initialization, lifecycle events, ad breaks, and verification with Poki Inspector.
Key features
- 01Loads and initializes Poki SDK
- 02Signals game loading completion
- 03Pairs gameplay start and stop events
- 04Adds interstitial and rewarded breaks
- 05Verifies flows with Poki Inspector
Use cases
- 01Integrating Poki into a game
- 02Coordinating play sessions with lifecycle events
- 03Testing ad breaks and pause-resume behavior
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ hungify/ playables-skills --skill poki-js-sdkAfter installing, type/poki-js-sdkin Claude Code to confirm it loaded.
Details
From the project READMEPoki JavaScript SDK
Integration Workflow
- Add the SDK script — embed or dynamically inject the Poki script tag.
- Initialize — call
PokiSDK.init()and resolvegameLoadingFinishedwhen the game is ready. - Verify init — check the browser console for Poki SDK handshake messages; use the Poki Inspector dev tool to confirm the session started.
- Add lifecycle hooks — call
gameplayStart/gameplayStoparound every play session. - Add ad breaks — insert
commercialBreakat natural pause points; addrewardedBreakwhere the player can opt in. - Test in Poki Inspector — open
https://inspector.poki.io, load your game URL, and trigger each ad break to confirm the flow.
Installation
Add the official Poki SDK script to your page:
<script src="https://game-cdn.poki.com/scripts/v2/poki-sdk.js"></script>
Or inject it dynamically:
function loadPokiSdk() {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = 'https://game-cdn.poki.com/scripts/v2/poki-sdk.js';
script.onload = resolve;
script.onerror = reject;
document.head.appendChild(script);
});
}
Initialization
loadPokiSdk()
.then(() => window.PokiSDK.init())
.then(() => {
// SDK is ready
window.PokiSDK.gameLoadingFinished();
})
.catch(() => {
// SDK init failed - continue without Poki integration
window.PokiSDK && window.PokiSDK.gameLoadingFinished();
});
Call gameLoadingFinished when the game is ready for the player. If your loader has discrete phases, bracket them with gameLoadingStart and gameLoadingFinished.
Advertisement
Interstitial
Use the isOpened flag to detect whether an ad was actually delivered — the callback is not invoked when no ad is shown.
function showInterstitial() {
let isOpened = false;
window.PokiSDK.commercialBreak(() => {
isOpened = true;
// Pause game, mute audio
})
.then(() => {
if (isOpened) {
// Resume game, unmute audio
} else {
// Ad was not shown
}
})
.catch(() => {
// Ad request failed
});
}
Rewarded
rewardedBreak resolves with a boolean — grant the reward only when both isOpened is true and the resolved value is truthy.
function showRewarded() {
let isOpened = false;
window.PokiSDK.rewardedBreak(() => {
isOpened = true;
// Pause game, mute audio
})
.then((success) => {
if (isOpened) {
if (success) {
// Grant reward to the player
}
// Resume game, unmute audio
} else {
// Ad was not shown
}
})
.catch(() => {
// Ad request failed
});
}
Lifecycle
Call gameplayStart when the player gains control (level start, level resume) and gameplayStop when control is taken away (level paused, completed, failed, or returning to a menu). Pair every gameplayStart with a matching gameplayStop.
function onLevelStart() {
window.PokiSDK.gameplayStart();
}
function onLevelEnd() {
window.PokiSDK.gameplayStop();
}
Testing & Verification
- Open Poki Inspector at
https://inspector.poki.ioand load your game URL to get a developer session. - The browser console will print Poki SDK handshake and event messages — confirm
initresolves andgameLoadingFinishedis acknowledged. - Trigger
commercialBreakandrewardedBreakvia the Inspector UI to simulate ad delivery and verify pause/resume logic fires correctly. - Confirm
gameplayStartandgameplayStopevents appear in the Inspector timeline at the correct moments.
Notes on omitted features: this skill does not cover server time, ad-block detection, happyTime, or gameInteractive; keep the implementation focused on the Poki SDK features listed above.