Overview
Client-side integration with Phoenix Games
Client Integration Overview
This section covers how to integrate Phoenix Games on the client side of your platform.
Integration Components
- Iframe Embedding: How to properly embed game iframes with authentication
- Events from Iframe: Handle events sent by the game to your platform
- Events to Iframe: Send events from your platform to the game
Authentication Flow
- User requests to play a game on your platform
- Your frontend calls your backend to generate a JWT token
- Your backend creates the token using the player's current balance
- Embed the game iframe with the token as a URL parameter
- Handle bidirectional events between your platform and the game
Security Considerations
- Never generate JWT tokens on the client side
- Always validate user sessions before requesting tokens
- Handle iframe communication securely using postMessage API
- Validate all events received from the game iframe