This version (v0.7) has not been published to npm yet.
Skip to content

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 ​

FirstFrameTarget

handlers ​

FirstFrameHandlers

options? ​

ConnectFirstFrameOptions = {}

Returns ​

FirstFrame

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.