mcpField
P
poki-js-sdk

poki-js-sdk

github.com/hungifyDevelopment016 installsUpdated 1w ago
Repository

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

  1. 01Loads and initializes Poki SDK
  2. 02Signals game loading completion
  3. 03Pairs gameplay start and stop events
  4. 04Adds interstitial and rewarded breaks
  5. 05Verifies flows with Poki Inspector

Use cases

  1. 01Integrating Poki into a game
  2. 02Coordinating play sessions with lifecycle events
  3. 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-sdk

After installing, type/poki-js-sdkin Claude Code to confirm it loaded.

Details

From the project README

Poki JavaScript SDK

Integration Workflow

  1. Add the SDK script — embed or dynamically inject the Poki script tag.
  2. Initialize — call PokiSDK.init() and resolve gameLoadingFinished when the game is ready.
  3. Verify init — check the browser console for Poki SDK handshake messages; use the Poki Inspector dev tool to confirm the session started.
  4. Add lifecycle hooks — call gameplayStart / gameplayStop around every play session.
  5. Add ad breaks — insert commercialBreak at natural pause points; add rewardedBreak where the player can opt in.
  6. 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.io and load your game URL to get a developer session.
  • The browser console will print Poki SDK handshake and event messages — confirm init resolves and gameLoadingFinished is acknowledged.
  • Trigger commercialBreak and rewardedBreak via the Inspector UI to simulate ad delivery and verify pause/resume logic fires correctly.
  • Confirm gameplayStart and gameplayStop events 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.

Comments

Markdown supported