Reference / @getenginex/sdk-igaming/first-frame / connectFirstFrame
connectFirstFrame()
connectFirstFrame(
iframe,handlers,options?):FirstFrame
Connects to the FIRST sportsbook iframe: receives FIRST's events in typed handlers and sends commands with send. It only delivers messages whose origin is the src origin of the iframe and whose source is the iframe's contentWindow; invalid JSON or JSON without eventType is ignored without throwing. The payload arrives as FIRST sent it (unknown): validate before using it.
Parameters
iframe
handlers
options?
Returns
Example
ts
import { connectFirstFrame } from '@getenginex/sdk-igaming/first-frame'
const frame = connectFirstFrame(iframe, {
onBetPlaced: () => void enginex.wallet.getBalance().then(showBalance),
onLoginRequired: () => openLogin(),
})
// when unmounting the iframe:
frame.dispose()Throws
CONFIGURATION_ERROR if the window (options.window or globalThis) has no addEventListener/removeEventListener.