# PlayDrop client SDK for browser games

Optional browser SDK for any PlayDrop game: host lifecycle, sign-in, saves, leaderboards, purchases, ads, friends, multiplayer and shared libraries, with one script tag.

Source: https://www.playdrop.ai/docs/sdk

The PlayDrop SDK is optional: games without it play on PlayDrop. Add it for platform features such as player sign-in, saves, achievements and leaderboards, purchases in credits, ads, friends and game cards in PlayDrop Chat, share links, host-managed pause and audio, hosted multiplayer and AI generation. [PlayDrop Cloud](https://www.playdrop.ai/create) integrates it for you; with [PlayDrop Connector](https://www.playdrop.ai/docs/connectors), your agent adds one script tag.

## Add the SDK and follow the host lifecycle

Load the SDK from PlayDrop's CDN; no package installation is needed. Render the first playable frame and prepare input before calling `sdk.host.ready()`. Pause simulation on host pause, resume without duplicate loops, and follow the host audio policy.

```html
<script src="https://assets.playdrop.ai/sdk/playdrop.js"></script>
<script type="module">
  const sdk = await playdrop.init();
  // Render the game and prepare input, then:
  sdk.host.ready();
  sdk.host.onPause(() => pauseGame());
  sdk.host.onResume(() => resumeGame());
  sdk.host.onAudioPolicyChange(({ enabled }) => setAudioEnabled(enabled));
</script>
```

## Identity, saves and language

`sdk.me` exposes player identity and `sdk.me.appData` stores private saves; `sdk.achievements` and `sdk.leaderboards` handle achievements and scores. Saves, achievements and leaderboards work without a login pre-check. Use `sdk.me.isLoggedIn` for features that require a real account, such as purchases or multiplayer. Preview and capture modes must not write player progress. `sdk.host.locale` gives the player's language: ship English plus your own language when it is different. Translating a listing does not translate game content.

## Libraries, assets and multiplayer

`sdk.libs` loads supported Three.js, Phaser, Rapier, nipplejs and Colyseus versions. `sdk.assets` provides catalog, pack and asset references; `sdk.social` provides friends, game cards and share actions. For hosted multiplayer, `sdk.multiplayer.getConnection()` returns the server address and the signed-in player's token; join with the Colyseus client. The [server SDK](https://www.playdrop.ai/docs/server-sdk) page covers hosted servers; a server you run yourself needs nothing from the SDK. The old relay room APIs are retired.

## Test with the SDK before you publish

Run your usual dev server and open `https://www.playdrop.ai/creators/<username>/apps/game/<slug>/dev?url=http://localhost:5173/` in Chrome to play it inside the real PlayDrop frame with the SDK host. Any localhost port or https URL works. Features that need an account, such as saves and purchases, work once the game has been uploaded once; a private upload is enough. Browser media generation runs as asynchronous tasks with a host-confirmed credit cost. See [catalogue.json](https://www.playdrop.ai/docs/catalogue-json) for listing metadata.
