Appearance
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):
| Package | Range |
|---|---|
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 | ||
|---|---|---|
siteId | required | The site the host serves |
apiBase | default https://api.oddyne.com | The prefix in front of /api/... |
wsBase | default wss://api.oddyne.com/ws/feed | The live socket; a path is resolved against the page's origin |
token | default null | The player's session token. null browses anonymously |
lang, currency, oddsFormat | Initial values; oddsFormat is decimal, fractional, american, hongkong, malay, indo | |
timezone | default the browser's | IANA zone of the player; "today" lists follow it |
device | desktop | mobile | |
i18n | The host's i18next instance; core's copy goes to namespace (default sportsbook) | |
callbacks | Below |
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.
| Callback | When |
|---|---|
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 route | Core |
|---|---|
/sports | useSportMenus, useTopEvents, usePopularTournaments |
/sports/live | useLiveList |
/sports/:sport/:category/:tournament | useTournamentEvents({ tournamentId }), useCategoryEvents({ categoryId }) |
/sports/event/:id | useEventDetail({ matchId }), useEventStatistic(…) |
/sports/results | useResultsSportMenu, useResultsAllCompetitions, useResultsTournamentEvents |
/sports/search | useSearch |
/sports/my-bets | useOpenTickets, 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.
| Screen | Subpath | Hooks, atoms |
|---|---|---|
| Sports tree, top menu | oddyne/common | useSportMenus, useTopMenu, useIntervalCounts, usePopularTournaments |
| Prematch lists | oddyne/prematch | useEventList, useTopEvents, useTournamentEvents, useCategoryEvents |
| Live list | oddyne/live | useLiveList, liveSportMenuAtom, useFeedConnection, useAnnouncements |
| Event page, markets | oddyne/common | useEventDetail, useMatchDetail, useMatch, useEventStatistic, useRunningEventTime, useOutrightDetail, useOutrightEvents |
| Betslip | oddyne/betslip | toggleSelectionAtom, removeSelectionAtom, setCurrentSelectionsAtom, setPerBetStakeAtom, setSingleStakeAtom, setSelectionTypeStakeAtom, toggleBankerAtom, setAcceptOddsChangeAtom, acceptOddsChangesAtom, betslipStateAtom, betslipCalculationAtom, betslipValidationAtom, placeBetAtom, placeBetStatusAtom, placeBetFailuresAtom, placedTicketsAtom, reuseTicketAtom |
| Bet builder | oddyne/betbuilder | openBuilderAtom, toggleBuilderLegAtom, requestBuilderQuoteAtom, builderQuoteAtom, placeBuilderBetAtom, placeCombiBuilderBetAtom |
| Open and settled bets | oddyne/ticket | useOpenTickets, useTickets, openTicketsAtom, settledTicketsAtom, useCancelBet |
| Cashout | oddyne/ticket | useCashout (quote, partial, full), useAutoCashout, useOfferHistory, cashoutTicketsAtom |
| Results | oddyne/results | useResultsSportMenu, useResultsAllCompetitions, useResultsTournamentEvents |
| Search | oddyne/search | useSearch, recentSearchesAtom |
| Trends | oddyne/trends | useTopBets, useTopParlays, useTopWinners |
| Status, maintenance | oddyne/config | useSportsbookStatus (polls GET /api/GetStatus: ok, degraded, maintenance; betting.prematch / betting.live) |
| Config and limits | oddyne/config | siteConfigurationAtom, siteCurrenciesAtom, siteLanguagesAtom, sysSettingsAtom, riskLimitsAtom, cashoutSettingsAtom, oddSettingsAtom |
| Session, language | oddyne/app | isAuthenticatedAtom, 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.