Skip to content

Launching Games

When a user clicks a game tile, the frontend must request a secure launchUrl from the backend. The backend communicates with the game provider, establishes a session, and returns the URL to load in an <iframe>.

Launch Modes

  • REAL: Plays with real money. Requires the user to be authenticated and have a wallet. The game provider will read/update the user's balance directly.
  • DEMO: Free play. Does not require real money. Note: Not all games support Demo mode (e.g., Live Casino games).

Initiating the Launch

javascript
try {
  const session = await sdk.games.launchGame('game_sweet_bonanza', 'REAL');
  
  // Inject into the DOM
  document.getElementById('game-iframe').src = session.launchUrl;
  
} catch (error) {
  if (error.message === 'Demo mode is not available for this game.') {
    // Show UI error: "This game does not support free play."
  } else {
    // Handle other errors (e.g., not authenticated)
  }
}

Session Interface

typescript
interface GameSession {
  sessionId: string;
  launchUrl: string; // The URL to embed in an <iframe>
  mode: 'REAL' | 'DEMO';
}

Security

The launchGame method automatically attaches the user's JWT Access Token. If the token has expired, the SDK's 401 Auto-Retry interceptor will silently refresh it before attempting to launch the game, ensuring a seamless user experience.