Skip to Content
The new glomex player is released! 🎉View upgrade guide

Interface: SharedContext

A global context singleton shared by every <glomex-integration> instance on the page.

Examples

const { sharedContext } = await import('https://player.glomex.com/integration/1/integration.js'); 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 { getSharedContext } from '@glomex/integration-react'; import { useEffect } from 'react'; function App() { useEffect(() => { async function setup() { const sharedContext = await getSharedContext(); 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(), }), }, }); } setup(); }, []); }

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