TikTok for Developers

Developer Docs

Last updated October 1, 2026

Event

These APIs allow the game to listen to or retrieve information about its transition between the foreground and background states.

API

Description

Context

.onShow(cb)


Listener: Registers a callback when the Mini Game comes back to the foreground (becomes visible) from the background.

Useful for pausing/resuming game action and checking for parameters passed during re-entry.

.offShow(cb)

Cancels the onShow listener.

--

.onHide(cb)

Listener: Registers a callback when the Mini Game is sent to the background (hidden).

Critical for saving game state and pausing resource consumption.

.offHide(cb)

Cancels the onHide listener.

--

.getLaunchOptionsSync

Synchronous: Retrieves the parameters used when the Mini Game was cold-started (opened for the first time in the session).

Returns object containing scene (entry point) and query (URL parameters).

.getEnterOptionsSync

Synchronous: Retrieves the parameters used for any start (cold start or hot start/return from background).

Provides consistent entry parameters regardless of the starting state.

TTMinis.game.onShow(listener)

Registers a listener for the event that is called when the mini game returns to the foreground.

Parameters

Field

Type

Description

Required

listener

function

The listener function for the mini game returning to the foreground

Yes

Listener callback parameters

Field

Type

Description

scene

string

Scene value

query

object

Query parameters

Example

TTMinis.game.onShow((result) => {
  let query = result.query;
  // do something when mini game shows
});

TTMinis.game.offShow(listener)

Removes the listener for the mini game returning to the foreground event.

Parameters

Field

Type

Description

Required

listener

function

The same listener function that was passed to onShow

Yes

Example

const listener = function (res) { console.log(res) }

TTMinis.game.onShow(listener)
TTMinis.game.offShow(listener) // Must pass the same function object used during registration

TTMinis.game.onHide(listener)

Registers a listener for the event that is called when the mini game is hidden to the background.

Parameters

Field

Type

Description

Required

listener

function

The listener function for the mini game being hidden to the background

Yes

Example

TTMinis.game.onHide(() => {
  // do something when mini game hides
});

TTMinis.game.offHide(listener)

Removes the listener for the mini game being hidden to the background event.

Parameters

Field

Type

Description

Required

listener

function

The same listener function that was passed to onHide

Yes

Example

const listener = function (res) { console.log(res) }

TTMinis.game.onHide(listener)
TTMinis.game.offHide(listener) // Must pass the same function object used during registration

TTMinis.game.getLaunchOptionsSync()

Gets the launch parameters of the mini game during cold start synchronously.

Returns

Launch parameters.

Field

Type

Description

scene

string

The scene value used to launch the mini game

query

object

The query parameters used to launch the mini game

Scene values

Scene

Description

scan_qrcode

Entered by scanning a QR code

search

Entered by search

anchor

Entered via anchor mount

center

Entered via sidebar re-visit entry

ads

Entered via advertisement

desktop_shortcut

Entered via desktop shortcut

dm_sharing

Entered via direct message sharing

minis_link

Entered via minis link

Example

const launchOptions = TTMinis.game.getLaunchOptionsSync()

TTMinis.game.getEnterOptionsSync()

Gets the enter parameters of the mini game (including both cold start and warm start) synchronously.

Returns

Launch parameters.

Field

Type

Description

scene

string

The scene value used to launch the mini game

query

object

The query parameters used to launch the mini game

Example

const enterOptions = TTMinis.game.getEnterOptionsSync()
TikTok for Developers