> For the complete documentation index, see [llms.txt](https://docs.elitebundleapp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.elitebundleapp.com/reference/globals.md).

# Global object

Reference for window\.eliteBundle: shop-level values, the current bundle data and the optional SDK object exposed on Shopify bundle pages.

```ts
window.eliteBundle = {
  version: string;
  app:  EliteBundleApp;          // shop-level values
  byob: BundleData | null;       // this page's bundle, if any
  sdk?: { byob: BundleSDK | null };
  on(event: string, cb: EventListener): void;
  off(event: string, cb: EventListener): void;
}
```

Two things load at different times, which matters if your script runs early:

* **`app` and `byob`** are written by the theme app embed in `<head>`, so they are there before any other JavaScript runs.
* **`version`, `sdk`, `on` and `off`** are added by the bundle script, which is deferred. `window.eliteBundle` can therefore exist while `sdk` is still undefined.

Never treat a missing `sdk` as "SDK access is off" — wait for `elite:byob:ready` on `document` instead. See [Event timing](https://docs.elitebundleapp.com/reference/events.md#event-timing).

`sdk` is only populated when SDK access is enabled in **Settings → Developer SDK**. Always use `window.eliteBundle.sdk?.byob`.

> The global carries a few internal keys beyond those listed here, such as the bundle registry and upsell data. They back the app's own storefront behaviour, are not part of the public API, and can change without notice — please do not build on anything undocumented.

***

## `app`

Shop-level values, available synchronously.

| Field                   | Type             | Description                                                                                                 |
| ----------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------- |
| `shopDomain`            | `string`         | The storefront domain the page was requested on                                                             |
| `moneyFormat`           | `string`         | Shopify money format string, e.g. `"${{amount}}"`                                                           |
| `currencyCode`          | `string`         | ISO 4217 currency code of the buyer's active currency                                                       |
| `currencyRate`          | `number`         | Exchange rate from the shop's base currency to the buyer's. `1` when they match. Added by the bundle script |
| `countryCode`           | `string`         | ISO 3166-1 alpha-2 market country                                                                           |
| `locale`                | `string`         | Buyer's active language ISO code, e.g. `"en"`                                                               |
| `storefrontAccessToken` | `string \| null` | Storefront API token, if you need to make your own Storefront API calls                                     |
| `sdkEnabled`            | `boolean`        | Whether SDK access is enabled for this shop                                                                 |

```js
const { moneyFormat, currencyCode, locale } = window.eliteBundle.app;
```

Other fields on `app` reflect internal setup state and are not part of the public API.

***

## `byob`

The bundle on the current page, **for every bundle type**. It is `null` (or absent, before the bundle script runs) on any page without a bundle, so always guard access. On a fixed bundle's page it is set, but `sdk.byob` stays empty: Shopify sells that bundle as a normal product.

| Field              | Type                       | Description                                                    |
| ------------------ | -------------------------- | -------------------------------------------------------------- |
| `bundleConfig`     | `object`                   | The bundle's stored configuration, in an internal encoded form |
| `shopifyVariantId` | `number \| string \| null` | Variant ID of the bundle product                               |
| `productId`        | `string`                   | Shopify product ID. Stable identifier for this bundle          |

```js
const bundle = window.eliteBundle.byob;
if (bundle) {
  console.log(bundle.productId);
}
```

> **`bundleConfig` is not a public API.** It is a compact encoded form written for the storefront's own decoder — keys are abbreviated and products are stored as bare IDs with no titles, images or prices. Its shape can change without notice. For anything you want to read or render, use the [Bundle SDK](https://docs.elitebundleapp.com/reference/sdk.md), which gives you the same data fully resolved.

***

## `on` / `off`

Convenience wrappers around `document.addEventListener` / `removeEventListener`. Added by the bundle script, so early theme code should call `document.addEventListener` directly.

```js
function handleCartChange(event) {
  updateMyCartUI(event.detail.cart);
}

window.eliteBundle.on('elite:byob:cart-change', handleCartChange);
window.eliteBundle.off('elite:byob:cart-change', handleCartChange);
```

See the [Events Reference](https://docs.elitebundleapp.com/reference/events.md) for every available event.

***

## `embed` / `closeEmbed`

Show a build your own bundle inside any element, on a page that is not the bundle's own. The Bundle On Any Page app block uses the same call; use it directly when your own section decides which bundle to show, for example three cards that each open a different bundle in place.

```js
const container = document.querySelector('#my-bundle');

// The ID is on the bundle's Publish tab, under "Show on any page".
const shown = await window.eliteBundle.embed(container, '15553083506967');

// Later, to go back to your cards:
window.eliteBundle.closeEmbed();
```

* `embed(element, bundleId)` resolves `true` once the bundle is mounted, and `false` when there is nothing to show: a wrong ID, a draft, or a bundle that is not build your own.
* One bundle shows at a time. A second `embed` closes the first, and the shopper's picks in it are cleared.
* On a bundle's own product page it does nothing and resolves `false`.
* Both are added by the bundle script. Call them from a click handler, or after `DOMContentLoaded`, not from inline code that runs earlier.
* The bundle's styles and your shop's custom CSS load with the first `embed`. The Elite Embed Core app embed must be on.
