3JS Games
Browse documentation

SDK / Beta

Player Identity

Read the current signed-in player's minimal public 3JSGames identity.

Install SDK v3

Vendor the exact official artifact at 3jsgames-sdk/v3/3jsgames.js and load it before your game script.

<script src="./3jsgames-sdk/v3/3jsgames.js"></script>
Engagement integrity. The unchanged SDK performs the player-ready handshake and reports the first qualifying pointer, touch, keyboard, or gamepad interaction to the trusted parent. An iframe load by itself is never counted as a play.

Public API

ThreeJSGames.player.getProfile() takes no arguments and resolves with exactly { username: string }.

try {
  const player = await ThreeJSGames.player.getProfile();
  console.log(`Playing as ${player.username}`);
} catch (error) {
  if (error.code === "AUTH_REQUIRED") {
    // Player is signed out. Keep gameplay working as a guest.
  } else {
    // Player Identity is unavailable. Keep gameplay working.
  }
}
Public presentation only. Username is globally unique but may change. Never use it as authorization, a permanent immutable ID, or a durable database key.

Privacy

The method returns only the public username. It does not expose an internal user ID, email, display name, avatar, token, provider, or private profile metadata, and it cannot look up another player.

Stable errors

  • AUTH_REQUIRED โ€” the player is signed out.
  • PLAYER_UNAVAILABLE โ€” identity or the platform bridge is unavailable.
  • INVALID_GAME_CONTEXT or CONTEXT_EXPIRED โ€” reload the embedded game.
  • RATE_LIMITED โ€” retry later.
  • REQUEST_TIMEOUT โ€” the request timed out.

Standalone games must catch unavailable errors and keep gameplay functional.