Frontend IntegrationUI component - React

React Component

Use @codemodity/betting-ui-react when your host application is built with React and you want the sportsbook mounted directly in the page. The package injects the environment’s sportsbook.js script and forwards your props to window.Sportsbook.mount().

If you need a cross-origin iframe embed, custom iframe wrapper, postMessage integration, or URL deep links, see Iframe Integration.

Install

npm i @codemodity/betting-ui-react

Usage

Import the Sportsbook component from the library and place it anywhere on your page. For the best user experience, let the component occupy the full available width. On mobile devices, it should be allowed to use the full screen width.

import { Sportsbook } from '@codemodity/betting-ui-react'
 
function YourSportsbookPage() {
    return (
        <Sportsbook
            tenantRef="exampleTenant"
            authToken="yourAuthToken"
            language="en-US"
            currency="USD"
            themeId="dark"
            environment="production"
            isTestMode={false}
            isUsLayout={false}
            topMenu={['search', 'home', 'live', 'my-bets', 'all-sports']}
            styles={{
                appHeight: '100%',
                background: '220 27.27% 6.47%',
                classnames: {
                    betslip: {
                        trigger: 'betslip-trigger',
                        content: 'betslip-content',
                    },
                },
            }}
            onRequireLogin={() => console.log('Login required')}
            onSessionExpiredReload={() => window.location.reload()}
            getBalance={async () => 100}
            onLoad={() => console.log('Sportsbook loaded')}
            hideLoading={false}
            loadingSpinnerElement={<div>Loading...</div>}
        />
    )
}

tenantRef is required. authToken can be omitted only for unauthenticated preview flows, depending on your tenant configuration.

Environment

The environment prop selects the hosted sportsbook bundle loaded by the component.

environmentScript base URL
qahttps://betting-qa.sportsmodity.com
devhttps://betting-dev.sportsmodity.com
mex-qahttps://betting-qa-mxce1.sportsmodity.com
mex-demohttps://betting-demo-mxce1.sportsmodity.com
mex-staginghttps://betting-staging-mxce1.sportsmodity.com

Custom environment names are also accepted. They resolve to https://betting-{environment}.sportsmodity.com.

Props

PropRequiredTypeNotes
tenantRefYesstringTenant identifier provided during integration setup.
authTokenNostringPlayer session token. Required for authenticated betting.
languageNostringLanguage code, for example en, en-GB, en-US, or ja.
currencyNostringWallet currency code, for example USD or GCOIN.
themeIdNostringTheme preset, for example dark, light, or system.
environmentNostringSelects the sportsbook script base URL. Defaults to qa.
isUsLayoutNobooleanEnables US-style layout when true.
isTestModeNobooleanEnables test API behavior.
topMenuNoTopMenuItemType[]Allowed values: search, home, live, my-bets, all-sports, dynamic.
stylesNoAppStylesContainer height, background, and host class names.
onRequireLoginNo() => voidCalled when an unauthenticated user attempts a gated action.
onSessionExpiredReloadNo() => voidCalled when the sportsbook session expires.
getBalanceNo() => number | null | undefined | Promise<number | null | undefined>Returns the current wallet balance for betslip validation.
onLoadNo() => voidCalled when the sportsbook finishes loading.
hideLoadingNobooleanHides the sportsbook bundle’s built-in loading state.
loadingSpinnerElementNoReactNodeReact overlay shown until onLoad fires.
hostElementSelectorNostringAdvanced. The React wrapper renders #sportsbookRoot; only change this if you fully control the mount target.
betslipClassnamesNo{ trigger?: string; content?: string }Deprecated. Use styles.classnames.betslip instead.
homeClassnamesNo{ featuredHeaderWrapper?: string }Deprecated. Use styles.classnames.home instead.

Styles

Use styles for host-level layout and class hooks:

<Sportsbook
    tenantRef="exampleTenant"
    styles={{
        appHeight: '100%',
        background: '220 27.27% 6.47%',
        classnames: {
            betslip: {
                trigger: 'betslip-trigger',
                content: 'betslip-content',
            },
            home: {
                featuredHeaderWrapper: 'featured-header-wrapper',
            },
        },
    }}
/>

styles.background uses HSL components only, without the hsl() wrapper.

Authentication callbacks

The host application owns login and session refresh behavior. When the sportsbook needs the player to authenticate, onRequireLogin is called. When the session expires, onSessionExpiredReload is called.

<Sportsbook tenantRef="exampleTenant" authToken={authToken} onRequireLogin={() => openLoginModal()} onSessionExpiredReload={() => window.location.reload()} />

When tenantRef, authToken, language, currency, themeId, layout, styles, callbacks, or topMenu change, the wrapper unmounts and remounts the sportsbook with the new values.

The React component does not expose a route prop. The sportsbook reads its route from the page URL query parameter sb-path, for example ?sb-path=live/soccer or ?sb-path=my-bets.

For iframe embeds and a full list of supported sb-path values, see Iframe Integration.