RetiPie
SDK

SDK Overview

Call window.retipie from your game to handle pause and resume, declare leaderboards, submit scores, and report analytics. Nothing to install.

The RetiPie SDK is the platform bridge added to every game. Creators call window.retipie from game code; RetiPie handles host communication, pause and resume, scoring, and loading and session signals.

The SDK is designed for indie browser games that need platform behavior without bundling third-party scripts.

Runtime surface

window.retipie = {
  game,
  leaderboards,
  analytics,
  ads,   // not active yet
  tips,  // not active yet
  version,
};

The ads and tips namespaces exist in the runtime but aren't active yet — platform monetization hasn't launched. In the RetiPie app, calling them is safe: the returned promises resolve with a failure result instead of throwing (completed: false with an error code for ads, tipped: false with errorCode: 'not_available' for tips). In the creator preview nothing answers the request, so the promise rejects after a timeout; wrap calls in try/catch. Documentation for them will be published when they go live.

What the SDK handles

  • Freezing your game automatically when the platform pauses it, and resuming it afterwards. See Game Lifecycle.
  • Leaderboard declarations and score submission.
  • Loading progress and gameplay start, stop, and restart markers.

Using the SDK from your game

Nothing to install

The platform adds the SDK to every game it serves — in the creator preview and in the feed. You don't install a package, add a <script> tag, or call an init function. Call window.retipie.* once your page loads.

if (window.retipie) {
  window.retipie.analytics.gameplayStart();
}

window.retipie is read-only and installed by the platform. Don't assign to it; code that tries to replace the bridge is flagged during upload checks. The guard above keeps your game working when you open the same build outside RetiPie, where the object doesn't exist.

TypeScript

There is no npm package for the SDK yet, so there is nothing to npm install. Until a types package is published, declare the parts you use in your own project:

// retipie.d.ts
interface RetiPieSdk {
  game: {
    configure(config: {
      leaderboards?: { default: { order: 'desc'; unit: 'points'; precision: 0 } };
    }): void;
    pause(): void;
    resume(): void;
    onPause(handler: () => void): () => void;
    onResume(handler: () => void): () => void;
  };
  leaderboards: { submitScore(score: number): void };
  analytics: {
    loadingProgress(percent: number): void;
    gameplayStart(): void;
    gameplayStop(): void;
    gameplayRestart(): void;
    trackEvent(
      name: string,
      data?: Record<string, string | number | boolean | null>,
    ): void;
  };
  version: string;
}

interface Window {
  retipie?: RetiPieSdk;
}

Engine wrappers

The core browser SDK powers the engine wrappers in this repository:

  • sdks/godot exposes a Godot 4 Web export addon backed by window.retipie.
  • sdks/unity exposes Unity WebGL C# bindings over the WebGL bridge.

See the Godot HTML5 export guide and Unity WebGL export guide for setup.

Next steps

On this page