Skip to content

Full Configuration Reference ​

ts
MindtrainingPlatform.init('mindtraining', {
  mode: 'full' | 'minimal', // default: 'full'
  game: { type: string, date?: string, category?: string | null } | null, // default: null
  showBackNavigation: boolean, // default: true
  showMobileGameHeader: boolean, // default: true
  showOtherGames: boolean, // default: true

  // ── Viewer ────────────────────────────────────────────────────────────────
  viewer: {
    userId: string | null,     // your user's ID
    loggedIn: boolean,         // default: false
    subscribed: boolean,       // default: false
  },

  // ── UI ────────────────────────────────────────────────────────────────────
  ui: {
    useHostShare?: boolean,
    colorScheme: 'light' | 'dark' | 'system', // default: 'light'
    mode: 'web' | 'app',       // default: 'web'
    safeAreaInsets: {          // optional, CSS pixels
      top?: number,
      right?: number,
      bottom?: number,
      left?: number,
    },
    actions: {
      shouldShowAccessPaywall: (context: {
        action?: 'login' | 'subscribe',
        mode: 'web' | 'app',
        surface?: 'today' | 'archive' | 'statistics' | 'trophies',
        reason?: 'login_required' | 'subscription_required' | 'host_rule' | 'variant_locked',
        limit?: 'meterLimit' | 'levelLimit',
        gameType?: string,
        variant?: string,
      }) => boolean,
      openLogin:       () => void,
      openRegister:    () => void,
      openSubscribe:   () => void,
      openUrl:         (url: string) => void,
      share:           (payload: { url?: string, title?: string }) => void,
    },
  },

  // ── Access ────────────────────────────────────────────────────────────────
  access: {
    home: {
      viewStatistics: boolean, // default: true
      viewTrophies: boolean, // default: true
      blockedReason?: BlockedReason,
      blockedReasons?: { default?: BlockedReason, statistics?: BlockedReason, trophies?: BlockedReason },
    },
    games: {
      [gameType]: {
        default: {
          playToday: boolean,        // default: true
          playArchive: boolean,      // default: true
          viewTrophies: boolean, // default: true
          viewStatistics: boolean,   // default: true
          saveState: boolean,        // default: true
          blockedReason: 'login_required'
                        | 'subscription_required'
                        | 'host_rule'
                        | 'variant_locked',
          blockedReasons: {
            default?: BlockedReason,
            today?:   BlockedReason,
            archive?: BlockedReason,
            statistics?: BlockedReason,
            trophies?: BlockedReason,
          },
          meterLimit: {
            maxStarts:    number,    // max game starts allowed
            intervalDays: number,    // rolling window in days
          },
          levelLimit: {
            maxLevel: number,        // max difficulty level allowed
          },
        },
        variants: {
          [variantId]: AccessPolicy, // same shape as default
        },
      },
    },
  },
})

Public SDK API ​

ts
type MindtrainingPlatformApi = {
  init: (
    containerOrConfig?: string | Element | PlatformInitConfig,
    config?: PlatformInitConfig
  ) => void
  updateConfig: (config?: Partial<PlatformInitConfig>) => PlatformInitConfig
  navigateHome: () => boolean
}

Use navigateHome() to return to the platform Home. It returns true if the navigation was handled, or false if navigation is not available yet.

ui.colorScheme ​

ui.colorScheme selects the color palette for all sites.

  • 'light' (default): forces the light palette.
  • 'dark': forces the dark palette.
  • 'system': follows the device preference through prefers-color-scheme and responds to changes while the platform is in use.

See UI actions for color scheme behavior and runtime examples.

ui.safeAreaInsets ​

Explicit safe-area values take precedence over CSS environment insets and can be changed with updateConfig(). Omitted edges keep the existing fallback. See Safe area insets.

All sites inherit the optional ui.actions.navigate callback. It receives a serializable request before SDK navigation. It works in both web and app modes. Navigation interception.

ui.useHostShare ​

Optional boolean in ui. Set true to delegate sharing to ui.actions.share in app and web, or false to use SDK sharing even with a registered callback. Omission preserves the app-only default. Without a callback, the SDK uses its existing sharing options. The callback return value is ignored. Change the option with updateConfig() without calling init() again or re-registering the callback. Omitting it in setConfig() restores the default.

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.

js
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.

Updating the user session ​

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.

Loaded SDK version ​

After the site script has loaded, call MindtrainingPlatform.getVersion() to read its embedded release version synchronously, for example "1.45". It reports the loaded site SDK, independently of the domain and the latest available release. Local or unpublished builds return "unreleased". Older scripts may not expose this method; check typeof MindtrainingPlatform.getVersion === 'function' before calling it when supporting older releases.

js
MindtrainingPlatform.getVersion()

Client integration documentation maintained in-repo.