Skip to Content

Interface: SharedContext

A global context singleton shared by every integration custom element instance on the page.

Examples

// Replace 'your-integration' with the actual element tag name // (e.g. 'glomex-integration', 'joyn-integration') await customElements.whenDefined('your-integration-tag'); const integration = document.querySelector('your-integration-tag'); const { sharedContext } = integration.constructor; sharedContext.set({ appVersion: '2.3.0', appName: 'my-app', deviceId: { id: '...', name: 'idfa' }, userIds: async () => await cmp.getConsentedUserIds(), providers: { 'my-provider': async () => ({ token: await myAuth.getFreshToken(), }), }, });
import { Integration } from '@turbo-player/integration-react'; function App() { return ( <Integration tagName="your-integration" moduleUrl="https://example.com/integration/1/integration.js" integrationId="REPLACE_WITH_INTEGRATION_ID" sharedContextData={{ appVersion: '2.3.0', appName: 'my-app', deviceId: { id: '...', name: 'idfa' }, userIds: async () => await cmp.getConsentedUserIds(), providers: { 'my-provider': async () => ({ token: await myAuth.getFreshToken(), }), }, }} /> ); }

Methods

set()

set(data): void

Merge context data into the shared context.

  • Provider resolvers under providers are merged individually — only the specified providers are replaced, others are kept.
  • Calling set() multiple times merges incrementally.

Parameters

data

SharedContextData

Returns

void

Last updated on