Integration
The betting frame allows seamless integration into partner websites, providing a complete betting experience with customization options for theming, localization, and event handling. The integration can be done either as a Single Page Application (SPA), with Server-Side Rendering (SSR), through the integration of individual widgets (Outside Widgets - only client), or you can integrate your own widget into betting (Custom Widget - only client), depending on your needs. A platform with its own betslip can keep it and let the frame drive only the odds (External betslip).
Configuration options
AppInitOptions
AppInitOptions is the top-level configuration object, which has the following structure:
1 2 3 4 5 6 7 8 | |
| Property | Description | Type | Required |
|---|---|---|---|
token | Token of the current player Token | string | yes |
rootElement | Identifier of the DOM element in which betting will be embedded | string | yes |
url | All endpoints for betting | BettingUrl | yes |
theme | Theme applied at load time. Overridden by an active theme preset. | Theme | no |
themePreset | Name of a theme preset to apply at load time. Recommended for SSR to avoid a theme flash. | string | no |
defaultSettings | Default settings for the SPA. | DefaultSettings | no |
Theming
The theme field sets the theme at load time. To switch themes at runtime (e.g. Light/Dark mode), define Theme Presets in the back-office and use setThemePreset - the deprecated updateThemeConfig is no longer the recommended approach.
For SSR integrations, pass the themePreset field with the preset name at load time. Otherwise the server renders the default preset first and the browser only switches to the selected preset at runtime, causing a visible theme flash (e.g. a light-to-dark jump on first paint).
BettingURL contains all the necessary endpoints for the SPA:
1 2 3 | |
| Property | Description | Type | Required |
|---|---|---|---|
basename | The basename field is used to specify the base URL for all relative links within the embedded betting. This is particularly useful when the application is deployed within a subdirectory of a domain. Often this will be something like /en/betting. | string | yes |
Default settings
DefaultSetting options are used to set the initial configuration of the application.
They define default values for various settings, such as display odds, which can later be changed by gambler.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
| Property | Description | Type | Default value | Required |
|---|---|---|---|---|
oddFormat | Default odd format for the SPA. | OddFormat | Decimal | false |
oddAcceptStrategy | Default odd accept strategy for the SPA. | OddAcceptStrategy | acceptAll | false |
Integration Bootstrap script
Bootstrap script is needed for integrations (SPA) or Outside Widgets into your product.
1. Add the bootstrap script
Include the script for the appropriate environment. Use the staging version during development and testing, and production for live deployment.
- Production:
1 2 3 4 5
<script type="module" defer src="https://spa.databet.cloud/v2/<project-name>/bootstrap.js" ></script> - Staging:
1 2 3 4 5
<script type="module" defer src="https://spa.int.databet.cloud/v2/<project-name>/bootstrap.js" ></script>
Warning
type="module" is required attribute
Note
This links will be provided by DATA.BET
SPA Integration
To integrate the betting SPA into your product, follow these steps:
1. Add DOM containers
You must include the following elements in your HTML layout:
- Main container — this is where the entire betting application will be rendered:
1 | |
- Betslip containers — separate element for betslip views:
1<div id="betting-betslip"></div>
Note
These elements must exist in the DOM before initializing the SPA
2. Add the bootstrap script
You need to integrate the bootstrap script.
3. Initialize the application
Once the script has loaded, a global object bettingLoader becomes available on the window. Use its load method to start the SPA:
1 2 3 4 5 6 | |
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
Important
Changes to the token require a page reload to take effect. This limitation is expected to be resolved in future updates.
4.Style the betslip containers
The SPA renders betslip view into dedicated container, depending on screen size:
React Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
Again, feel free to adapt this styling for your layout — e.g., adjusting height or position to avoid overlapping your app’s header or sidebar.
SSR Integration
The SSR (Server-Side Rendering) integration with the DATA.BET platform consists of two parts:
- Server-side integration — generating betting HTML fragments on the server.
- Client-side integration — initializing interactivity via the
bettingAPI.
1. Server-side integration
DATA.BET provides an SSR server that returns pre-rendered betting application HTML for a specific user route.
To integrate it, send a POST request to the SSR endpoint. The request URL must exactly match the path and query parameters the user is currently visiting (i.e., pathname + query).
The server endpoint depends on the environment:
- Production:
https://ssr.databet.cloud - Staging/Integration:
https://ssr.int.databet.cloud
Below is an example used on the demo site (Next.js):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
⚠️ Important Notes
1. Betting Token Management
The token field in AppInitOptions is required.
You are fully responsible for the management of this token in your application — including:
- Generation (e.g., via guest or login flow)
- Validation (e.g., signature or expiration)
- Storage (e.g., HTTP-only cookie or server session)
- Refresh or renewal (if applicable)
2. Device Layout Detection
The defaultLayout field in AppInitOptions defines how the betting UI should render: 'mobile', 'tablet', or 'desktop'.
This should be determined based on the user's device, typically by inspecting the User-Agent header In a Next.js App Router environment, use the userAgent utility to extract device info safely on the server:
1 2 3 4 5 | |
3. Request url
The SSR request must target the exact URL that corresponds to the user’s current location, including both the pathname and search components. This ensures that the returned betting content is accurate and relevant for the current route.
In a Next.js application, the current URL should be captured and forwarded via custom headers (e.g., x-url) using middleware. This allows the server component to reconstruct the user's location and perform the SSR request accordingly.
1 2 3 4 5 | |
4. Content Security Policy (nonce)
If your page is served with a nonce-based Content-Security-Policy (for example script-src 'nonce-…' 'strict-dynamic'), the browser executes only the <script> tags that carry the matching nonce attribute. The SSR fragment contains parser-inserted scripts (hydration data, the module entry) and <link rel="modulepreload"> tags, so without the nonce the browser blocks them and the betting application does not start.
Pass the nonce of the current page in the X-CSP-Nonce request header. The SSR server then sets nonce="…" on every <script> and <link rel="modulepreload"> in the response; nothing else in the markup changes. Do not post-process the returned HTML yourself.
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
The value must be a base64 string (A-Z a-z 0-9 + / - _, optional = padding), up to 256 characters; any other value is rejected with 400.
The client-side part needs nothing extra: the bootstrap script and the chunks it loads are created programmatically, which 'strict-dynamic' already trusts.
2. Client-side integration
Once the server-rendered HTML is loaded and hydrated on the client-side, the betting-init event is dispatched, signaling that window.bettingAPI is ready.
This API enables interaction with the embedded betting application: event subscriptions, register callback, etc.
Example (Client Component in Next.js):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
3. Fallback to SPA integration if SSR fails
If you are using SSR (Server-Side Rendering) integration and the SSR server responds with an error (for example, a 4xx/5xx HTTP status or a network failure), it is recommended to gracefully fall back to the SPA integration. This ensures that users can still access the betting application even if SSR is temporarily unavailable.
Steps to implement fallback:
-
Attempt SSR first:
Try to fetch the SSR-rendered HTML from your SSR endpoint as usual. -
Detect SSR failure:
If the SSR request fails (e.g., non-200 response, network error, or invalid HTML), proceed to load the SPA client-side. -
Initialize SPA via
bettingLoader:
Use the samebettingLoader.loadmethod as described above to bootstrap the SPA in the client browser.
Outside Widgets
How it works
Loading and initializing the bootstrap script only registers the widget custom element definitions with the browser — it does not insert any widgets into the DOM. To render a widget, you must also add its tag to your HTML markup (see step 3).
1. Add the bootstrap script
You need to integrate the bootstrap script.
2. Initialize the application
Once the script has loaded, a global object bettingLoader becomes available on the window. Call its loadWidgets method to register the custom elements with the browser:
1 2 3 4 5 6 | |
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
Note
Outside Widgets are themed by the configuration set in the back office. The style attribute on each widget element lets you optionally override individual CSS variables on top of that — see step 3 below.
3. Add the widget elements to your page
After loadWidgets() registers the custom elements, place the widget tags directly in your HTML wherever you want each widget to appear. If you omit this step, no widgets will be rendered, even if loadWidgets() completes successfully.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
Top events widget
1 2 3 4 5 6 | |
1 | |
1 | |
Top tournament widget
The widget displays a carousel of event cards for tournaments assigned to a featured zone. Players can place bets directly from these cards, so the Island Betslip Widget (island-betslip-widget) must also be added to the same page.
1 2 3 4 5 6 7 8 9 | |
| Attribute | Description |
|---|---|
zone-id | ID of the featured zone whose tournaments the widget shows. Your DATA.BET manager provides the zone IDs available for your project. |
type | firstActive shows the first tournament of the zone that has events. all shows all tournaments of the zone with a tab for each of them. |
status | Shows only live or only prematch events. If omitted, both are shown. |
limit | The maximum number of event cards in the carousel. |
with-title | Shows the widget header. Pass false to hide it. |
1 | |
Predictions: Crypto Up or Down
To show the Crypto Up or Down predictions, for example on the main page of your site, set zone-id to prediction_crypto:up_or_down and type to all:
1 2 3 4 5 | |
For a predictions zone, the widget works as follows:
- The header shows the Crypto Up or Down title and icon. Pass
with-title="false"to hide it. - The events are sorted so that the predictions closing soonest come first.
- With
type="all", the tabs filter the cards by asset: All and a tab for each asset that has active events, such as BTC, ETH, and SOL. The set of tabs is dynamic: a tab appears only while its asset has at least one active event, and it disappears once those events end. - With
type="firstActive", the widget shows the cards of all assets without the tabs. - The widget refreshes the list of tournaments and events automatically, so ended predictions are replaced with new ones without reloading the page.
- If the zone has no active events, the widget renders nothing.
Island Betslip Widget
1 2 3 | |
1 2 3 | |
End-to-end example
A working Outside Widgets integration needs three things wired together:
- the bootstrap script and
loadWidgets()call; - a betslip widget alongside the other widgets (players always need one to place bets);
- a subscription to the
redirectevent so users can navigate from a widget into a login flow or a specific event page.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
See Betting events for the full list of events you may want to subscribe to (e.g. handle-not-enough-balance to open a deposit modal).
Custom Widget
The Betting Frame supports custom widgets, allowing you to integrate your own content into the betting interface. Custom widgets subscribe to mount events from the betting API, enabling you to render custom content in designated containers using any framework or vanilla JavaScript.
Implementation
Custom widgets require:
- Event Subscription: Subscribe to
custom-widget-initevents from the betting API - DOM Manipulation: Use the provided DOM element to render custom content
- Event Handling: Handle mount events to get container information
Example (React)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
Note
This example shows a React implementation using createPortal. You can use any framework (Vue, Angular, vanilla JavaScript) to manipulate the DOM element provided in the event. The key is to use the element property from the event to render your custom content.
For more details about betting events, see Betting Events.

