Skip to main content

Game Bridge Architecture

Learn how Immutable game SDKs work internally and how to adapt them for custom engines.
This page is primarily for developers building custom engine integrations or wanting to understand the SDK architecture. If you’re using Unity or Unreal, refer to their respective SDK documentation.

Overview

The Unity and Unreal SDKs share a common architecture that bridges native game engines with TypeScript-based functionality. This design allows consistent behavior across platforms while leveraging platform-specific capabilities. The architecture has three main components: a game bridge for communication, an invisible WebView for executing TypeScript, and an in-app browser for secure authentication.

Architecture Diagrams

High-Level Architecture

Communication Flow

How the game engine communicates with TypeScript SDK packages through JSON serialization:

PKCE Authentication Flow

How authentication works using in-app browsers for security:

Core Components

1. Game Bridge

The game bridge enables string-based communication between your game engine and the TypeScript SDK. How it works:
  • The game-bridge package enables communication with TypeScript SDK packages
  • TypeScript packages are bundled into a single file loaded into an invisible WebView
  • The game SDK sends JSON string messages to the WebView and receives responses
Implementation: Both contain the bundled TypeScript SDK and game-bridge package.

2. WebView

An invisible WebView loads the game bridge and executes TypeScript SDK functionality. Requirements:
  • HTML/JavaScript loading support
  • Modern JavaScript (ES6+)
  • Bidirectional native-JavaScript communication
  • Hidden from user view (no UI rendering)
Platform considerations:
  • Mobile: Native WebView components (Android/iOS)
  • Desktop: May require embedded browser frameworks
  • Windows: CEF 90+ required

3. In-App Browser

Authentication uses an in-app browser (not WebView) for security and SSO compatibility. Requirements:
  • Secure, isolated browser context
  • Process isolation (runs separately from your app)
  • Deep link callback handling
  • System authentication session support
Never use WebView for authentication. In-app browsers run in separate processes, preventing credential theft and meeting OAuth 2.0 best practices. See Why in-app browser? for details.
For platform-specific implementations, see:

Adapting for Custom Engines

This section is for custom game engine integrations. Unity and Unreal users don’t need to modify these components.
To adapt the SDK for your custom engine, you’ll need to modify three areas:

1. Modify the Game Bridge

Keep the bundled TypeScript SDK but modify the callbackToGame() function in game-bridge/index.ts to communicate with your engine. After modification, rebuild the bundle following the game-bridge README.

2. Implement WebView Communication

Option A: Reuse our platform-native WebView implementations and adapt the communication layer Option B: Implement a custom WebView with bidirectional string communication and lifecycle management Reference implementation:

3. Implement PKCE Authentication

Reuse our platform-native PKCE implementations and deep linking handlers. Adapt the communication layer between your engine and native code for URL scheme registration and callback handling.
The Game SDK is lightweight—essentially a wrapper around the TypeScript SDK. Most complexity is in the bridge and WebView communication, not the SDK logic itself.