Skip to content

Frontend library ​

Draw the sportsbook in your own React app with oddyne-frontend-core — data, the live socket, the betslip, tickets and cashout — instead of embedding the iframe. The backend side (sessions, proxying the API) is in Native embedding.

A host app (an operator's own React platform) can draw the sportsbook itself and use core for everything behind the screen: data, the live socket, the betslip, tickets and cashout. This page is the contract for that use. The iframe themes keep working as before.

Load it ​

Core is a Module Federation remote. A host loads the library build, whose container is named oddyne so it can sit beside the host's own core remote:

ts
// module-federation config of the host
remotes: {
  oddyne: 'oddyne@https://cdn.oddyne.com/lib/v/<version>-<sha>/remoteEntry.js',
},

Pin a version. The library build has no latest: a host decides when it moves. The published versions are listed by the Admin API, newest first — GET /integration/v1/frontend-versions → [{ version, remoteEntry, publishedAt, latest }]. Poll it from your service and move the pin when you choose.

Host versions ​

Core shares these as singletons and accepts the host's copy within these ranges (the test suite passes at the top of each):

PackageRange
react, react-dom^19.1.1
jotai^2.14.0
@tanstack/react-query^5.89.0
i18next^25.5.2
react-i18next^15.7.3 || ^16.0.0
dayjs^1.11.18

react-hot-toast is not needed: core's messages reach the host through onMessage.

Start it ​

tsx
import { Provider } from 'oddyne/app';
import { createSportsbook } from 'oddyne/host';
import i18next from './i18n';

// the host's own instance

const sb = createSportsbook({
  siteId: 'brand-a',
  apiBase: '/sb', // the host proxies /sb/api/* → api.oddyne.com/api/*
  wsBase: '/sb/ws', // and /sb/ws → wss://api.oddyne.com/ws/feed
  token: sessionToken ?? null, // POST /api/session on the host's server; null = anonymous
  lang: 'tr',
  currency: 'TRY',
  oddsFormat: 'decimal',
  timezone: 'Europe/Istanbul',
  device: 'mobile',
  i18n: { instance: i18next, namespace: 'sportsbook' },
  callbacks: {
    onLoginRequired: (reason) => openLogin(reason),
    onSessionExpired: async () => sb.setToken(await mintSession()),
    onBetPlaced: ({ ticketId, stake, currency }) => track('bet', ticketId, stake, currency),
    onBalanceHint: () => refreshBalance(),
    onDeposit: ({ amountHint }) => openDeposit(amountHint),
    onError: (code) => log('sportsbook', code),
    onNavigate: (route) => navigate(toHostPath(route)),
    onMessage: (m) => toast[m.type](m.message),
  },
});

root.render(<Provider>{({ isAppReady }) => (isAppReady ? <SportsArea /> : <Spinner />)}</Provider>);

Call createSportsbook once, before rendering Provider. It replaces everything the iframe build reads from the launch URL and window.__ENV_CONFIG.

Option
siteIdrequiredThe site the host serves
apiBasedefault https://api.oddyne.comThe prefix in front of /api/...
wsBasedefault wss://api.oddyne.com/ws/feedThe live socket; a path is resolved against the page's origin
tokendefault nullThe player's session token. null browses anonymously
lang, currency, oddsFormatInitial values; oddsFormat is decimal, fractional, american, hongkong, malay, indo
timezonedefault the browser'sIANA zone of the player; "today" lists follow it
devicedesktop | mobile
i18nThe host's i18next instance; core's copy goes to namespace (default sportsbook)
callbacksBelow

It returns a controller:

setToken(token | null)Login, refresh, logout. User data refetches and the socket reconnects as the new player — no reload
setLanguage(lang)Lists, the socket and core's copy switch language. Core never changes the host's i18next language
setCallbacks(callbacks)Replaces the callbacks
destroy()Closes the socket and drops the callbacks (the sports area unmounts)

Local storage keys stay scoped by siteId.

Callbacks ​

Every callback is optional; one that throws is logged and never breaks core. Core does not post messages to a parent window in this mode.

CallbackWhen
onLoginRequired(reason)A player action needs a session and there is none (place_bet). The betslip is kept for after the login
onSessionExpired()The API refused the session (401/403). Mint a new one on your server and call setToken
onBetPlaced({ ticketId, stake, currency })Once per accepted ticket; stake is what the coupon cost
onBalanceHint()Money moved (a bet, a cashout): refresh the balance you show
onDeposit({ amountHint })A bet was refused for funds
onError(code)Every refusal code the player is shown (insufficient_funds, player_blocked, odd_changed, …)
onNavigate(route)Core, or a component of yours through requestNavigation(route), asks to go somewhere
onMessage({ module, code, message, type })Every message core would show (translated): render it as your toast, or not

Routing belongs to the host ​

Core never reads or writes the URL in this mode. The host owns its routes, for example:

Host routeCore
/sportsuseSportMenus, useTopEvents, usePopularTournaments
/sports/liveuseLiveList
/sports/:sport/:category/:tournamentuseTournamentEvents({ tournamentId }), useCategoryEvents({ categoryId })
/sports/event/:iduseEventDetail({ matchId }), useEventStatistic(…)
/sports/resultsuseResultsSportMenu, useResultsAllCompetitions, useResultsTournamentEvents
/sports/searchuseSearch
/sports/my-betsuseOpenTickets, useTickets, useCashout

The host passes the params from its router into the hooks; a reload of a deep link works because nothing in core depends on navigation history. onNavigate receives { name, params } (event + { matchId }, tournament + { tournamentId }, …) and the host maps it to its own path.

i18n ​

With i18n.instance set, core's copy lives in its own namespace of the host's instance (flat keys such as place_bet.insufficient_funds), so it never collides with the host's keys. Core loads its English fallbacks and the operator's copy (GET /api/GetUITranslations, per language, edited in the Admin API) into that namespace, and reloads it on setLanguage. Market and outcome names come from the API in the active language.

Refusal codes and their keys are PLACE_BET_ERROR_CODES / PLACE_BET_MESSAGE_KEYS (oddyne/ticket, oddyne/app).

Hooks for every screen (public API) ​

Each subpath is stable within a major version. Names are exported from the subpath shown.

ScreenSubpathHooks, atoms
Sports tree, top menuoddyne/commonuseSportMenus, useTopMenu, useIntervalCounts, usePopularTournaments
Prematch listsoddyne/prematchuseEventList, useTopEvents, useTournamentEvents, useCategoryEvents
Live listoddyne/liveuseLiveList, liveSportMenuAtom, useFeedConnection, useAnnouncements
Event page, marketsoddyne/commonuseEventDetail, useMatchDetail, useMatch, useEventStatistic, useRunningEventTime, useOutrightDetail, useOutrightEvents
Betslipoddyne/betsliptoggleSelectionAtom, removeSelectionAtom, setCurrentSelectionsAtom, setPerBetStakeAtom, setSingleStakeAtom, setSelectionTypeStakeAtom, toggleBankerAtom, setAcceptOddsChangeAtom, acceptOddsChangesAtom, betslipStateAtom, betslipCalculationAtom, betslipValidationAtom, placeBetAtom, placeBetStatusAtom, placeBetFailuresAtom, placedTicketsAtom, reuseTicketAtom
Bet builderoddyne/betbuilderopenBuilderAtom, toggleBuilderLegAtom, requestBuilderQuoteAtom, builderQuoteAtom, placeBuilderBetAtom, placeCombiBuilderBetAtom
Open and settled betsoddyne/ticketuseOpenTickets, useTickets, openTicketsAtom, settledTicketsAtom, useCancelBet
Cashoutoddyne/ticketuseCashout (quote, partial, full), useAutoCashout, useOfferHistory, cashoutTicketsAtom
Resultsoddyne/resultsuseResultsSportMenu, useResultsAllCompetitions, useResultsTournamentEvents
Searchoddyne/searchuseSearch, recentSearchesAtom
Trendsoddyne/trendsuseTopBets, useTopParlays, useTopWinners
Status, maintenanceoddyne/configuseSportsbookStatus (polls GET /api/GetStatus: ok, degraded, maintenance; betting.prematch / betting.live)
Config and limitsoddyne/configsiteConfigurationAtom, siteCurrenciesAtom, siteLanguagesAtom, sysSettingsAtom, riskLimitsAtom, cashoutSettingsAtom, oddSettingsAtom
Session, languageoddyne/appisAuthenticatedAtom, langAtom, oddFormatAtom, appMessagesAtom

Favourites are not part of core: a host keeps them itself.

The components core exports (EventList, Betslip, TicketList, …) are headless: render props, no styles. A host may use them or only the hooks; core ships no CSS, so the host's own design tokens apply.

Integration documentation for the Oddyne Sportsbook.