Updating Configuration at Runtime
If the user's session changes after initializing the platform (for example, they log in or out without reloading the page), call updateConfig() with the updated user data. The platform updates the content automatically and keeps the current page. You do not need to call init() again.
// User just logged in
MindtrainingPlatform.updateConfig({
viewer: {
userId: 'user-123',
loggedIn: true,
subscribed: false,
},
})updateConfig() updates only the properties you provide. All other settings keep their current values, including properties inside objects such as viewer and ui.
To log the user out, clear their session data:
MindtrainingPlatform.updateConfig({
viewer: { userId: null, loggedIn: false, subscribed: false },
publisherToken: null,
})Game embeds
Embed a single game in a newspaper page using the same script initializer. No data attributes are needed. Game embeds.
The game object is required in minimal mode. game.type is the API game type, not a title or URL. game.date is optional: omit it or use last for the latest publication, or provide a valid YYYY-MM-DD date. game.category is optional: omission or null selects the default configuration; a string selects that exact category. Unavailable or ambiguous selectors produce an error instead of choosing another game.
Use updateConfig() to change the mode or choose another game, passing the complete game object. In full mode, use game: null to clear the selection. Changing the game loads the new selection, so update it only when the user should switch games. mode is independent of ui.mode (web/app).
Home and trophies
The optional access.home policy controls the statistics overview and medal collection independently of game permissions, including direct routes. viewStatistics and viewTrophies are booleans defaulting to true. Game default/variant policies also accept viewTrophies (default true). Game cards remain visible in statistics and trophy overviews; opening a denied game shows its access policy instead of the detail. blockedReasons.trophies sets the trophy-specific reason. Reason priority is surface, default, then blockedReason. The host computes permissions for the current viewer; loggedIn alone does not block access. Missing policies remain permissive. Supported on every site that exposes these features. Runtime updates preserve omitted Home fields and unrelated game policies.
MindtrainingPlatform.updateConfig({
access: {
home: {
viewStatistics: false,
viewTrophies: false,
blockedReason: 'subscription_required',
},
games: {
crossword: {
default: {
viewTrophies: false,
blockedReasons: { trophies: 'subscription_required' },
},
},
},
},
})Publisher authentication
If your integration requires publisher authentication, pass publisherToken with the matching viewer.userId. Mindtraining will confirm whether this is required for your site. The platform handles authentication automatically. When your token changes, send it with updateConfig({ publisherToken: freshToken }); use publisherToken: null to remove it. When switching accounts, send the new user ID and token together.
When a guest signs in through init() or updateConfig(), pass the account ID and publisher token together. In required mode, the SDK links the browser’s guest progress to the verified account for the same Site and domain. If the account already has independent progress, both histories stay separate.