For the complete documentation index, see llms.txt. This page is also available as Markdown.

Navigation API (BETA)

Open RUN pages, navigate between games, and manage the app navigation stack.


Open a RUN page

Open an allowed RUN page inside the host app on web, iOS, Android, and the desktop client. The host keeps the current login session; it does not open a browser tab or load the page inside your game iframe.

Destination
Fields
Opens

{ page: 'jam', slug, gameId? }

Jam slug; optional game/content ID to highlight

Jam leaderboard and voting

{ page: 'jams' }

None

Jams hub

{ page: 'profile', username }

Creator's username, without @

Creator profile

{ page: 'catalog' }

None

Game catalog

For example, wire a "Vote for me" button to your jam entry:

import RundotGameAPI from '@series-inc/rundot-game-sdk/api'

document.querySelector('#vote-for-me')?.addEventListener('click', async () => {
  try {
    await RundotGameAPI.navigateToRunPage({
      page: 'jam',
      slug: 'your-jam-slug',
      gameId: 'your-game-id',
    })
  } catch (error) {
    console.error('Could not open jam voting', error)
  }
})
  • Save progress before calling. Navigation closes the game through the host's normal leave-game flow and clears game-to-game return context. Back does not automatically restore the game or unsaved state; players can relaunch it normally. Do not rely on code after a successful call running.

  • The optional gameId maps to the jam page's ?game= highlight. Omit it to open the general board. Opening the page does not cast a vote; the player must vote there, and voting prompts sign-in when required.

  • The host releases fullscreen and pointer lock before navigating. Steam Deck stays fullscreen but releases the cursor. If release fails, the request rejects without navigating.

  • Destinations are typed objects, not URLs or arbitrary routes. The host rejects unknown fields, path traversal, and reserved profile route names. Jam slugs use lowercase letters/numbers separated by single hyphens (maximum 200 characters); usernames use letters, numbers, hyphens, and underscores (maximum 38). An optional gameId must be a non-empty string of at most 512 characters without surrounding whitespace or control characters.

  • Call from a player action. No popup permission or browser gesture forwarding is needed because the host routes internally; the iframe sandbox is unchanged.

  • Mock and playground mode log the destination without leaving the game. Older hosts and shells without RUN-page routing can reject or time out; handle the error rather than falling back to window.open or top-frame navigation. Both the game SDK and host need this API available.


Game-to-Game Navigation

Launch another game from within your game, optionally passing data forward and preserving context for when the player returns.

Key Features:

  • Navigate the player to a different game by ID

  • Pass arbitrary data to the target game on launch

  • Receive data back when the player returns from the target game

  • Single-depth: only one level of return context is preserved

Quick Start

How It Works

  1. Navigate: Game A calls navigateToGame with the target game ID and optional context data. The current game is unmounted immediately.

  2. Target receives launch data: When Game B initializes, context.g2gLaunch contains whatever launchContext Game A provided.

  3. Return: When the player navigates back (via the host's back button), Game A re-initializes and context.g2gReturn contains the returnContext that Game A originally provided.

Complete Example

Game A, the source game:

Game B, the target game:

Navigate the player to another game. The current game is unmounted.

Parameters

Param
Type
Required
Description

targetGameId

string

Yes

The ID of the game to navigate to

options.launchContext

Record<string, any>

No

Data passed to the target game, available as context.g2gLaunch

options.returnContext

Record<string, any>

No

Data restored when returning to this game, available as context.g2gReturn

Reading G2G Context

After initialization, check RundotGameAPI.context for G2G data:

Field
Type
Present when

context.g2gLaunch

Record<string, any>

This game was launched via navigateToGame from another game

context.g2gReturn

Record<string, any>

The player returned from a game that this game navigated to

Both fields are undefined when the game is launched normally (not via G2G navigation).

Design Constraints

  • Single-depth only. If Game A navigates to Game B, and Game B navigates to Game C, only the B-to-C return context is preserved. Game A's return context is overwritten.

  • Session-scoped. G2G state is held in memory only and is not persisted across app restarts.

  • Current game is unmounted. After calling navigateToGame, your game is destroyed. Any unsaved state will be lost, so save before navigating.


Stack Navigation

Push and pop games onto a navigation stack managed by the host.

pushAppAsync(appId, options?)

Push a new game onto the navigation stack.

Param
Type
Required
Description

appId

string

Yes

The game to push onto the stack

options.contextData

any

No

Context data for the target game

options.appParams

any

No

App-specific parameters

popAppAsync()

Pop the current game off the navigation stack, returning to the game below.

getStackInfo()

Get information about the current navigation stack.

Returns: NavigationStackInfo

Field
Type
Description

isInStack

boolean

Whether the game is part of a navigation stack

stackPosition

number

Current position in the stack (0-indexed)

isTopOfStack

boolean

true when this game is the topmost (most recently pushed) entry in the stack

stackDepth

number

Total number of entries currently on the stack; compare against stackPosition to know where you sit

parentInstanceId

string

Instance ID of the game directly below this one (the game that pushed it); null when not in a stack

The public RundotGameAPI type currently declares only isInStack and stackPosition. The host returns all five fields at runtime, so to read isTopOfStack, stackDepth, or parentInstanceId in TypeScript you may need to cast the result to NavigationStackInfo.

requestPopOrQuit(options?)

Request to pop from the stack or quit the game, potentially showing a confirmation dialog.

Param
Type
Required
Description

options.reason

string

No

Reason for quitting

options.forceClose

boolean

No

Skip confirmation and force close

The options object accepts arbitrary additional keys beyond reason and forceClose (the type carries an index signature [key: string]: any); any extra keys are forwarded to the host.

Returns: boolean, true if the quit/pop was successful.


Best Practices

  • Save state before navigating. Both navigateToGame and pushAppAsync unmount your game. Persist anything important to storage first.

  • Check G2G context on every boot. Your game can be launched normally or via G2G, so always check context.g2gLaunch and context.g2gReturn and handle both paths.

  • Keep context payloads small. G2G context is held in session memory. Use IDs and short strings; fetch large data from your backend.

  • Don't chain G2G navigations deeply. Only one level of return context is preserved. If you need multi-step flows, use stack navigation instead.

Last updated