> For the complete documentation index, see [llms.txt](https://docs.liquidcommerce.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.liquidcommerce.cloud/elements-v2/configuration.md). Agents can also search and read this documentation through its [MCP server](https://docs.liquidcommerce.cloud/~gitbook/mcp).

# Configuration

This is the field-by-field reference for the configuration object accepted by `Elements()`, `ElementsBuilder()`, and `ElementsCheckout()` — every top-level key, its type, its default, and what happens when you get it wrong. For guided, example-driven walkthroughs of specific areas, this page links out to [Theming](https://docs.liquidcommerce.cloud/elements-v2/theming.md), [Advanced](https://docs.liquidcommerce.cloud/elements-v2/advanced.md), [Checkout](https://docs.liquidcommerce.cloud/elements-v2/checkout.md), and the [Quick Start Guide](https://docs.liquidcommerce.cloud/elements-v2/quick-start-guide.md).

> There are two independent ways to configure the SDK: **programmatic** (a JS object passed to `Elements(apiKey, config)`) and **declarative** (`data-*` attributes / JSON `<script>` tags on the auto-init script). This page documents the programmatic config object. For the declarative equivalent — attribute names, JSON script tags, and defaults — see the [Quick Start Guide](https://docs.liquidcommerce.cloud/elements-v2/quick-start-guide.md).

## Programmatic configuration

Three factory functions accept a config object with the same shape:

| Factory                             | Config type                                   | Resolves to                                                                                                                                                                         |
| ----------------------------------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Elements(apiKey, config?)`         | `ILiquidCommerceElementsConfig`               | `Promise<ILiquidCommerceElementsClient \| null>`                                                                                                                                    |
| `ElementsBuilder(apiKey, config?)`  | `ILiquidCommerceElementsBuilderConfig`        | `Promise<ILiquidCommerceElementsBuilderClient \| null>` (powers LiquidCommerce's internal builder/theme tooling; typical partner integrations use `Elements` or `ElementsCheckout`) |
| `ElementsCheckout(apiKey, config?)` | `ILiquidCommerceElementsCheckoutClientConfig` | `Promise<IElementsCheckoutClient \| null>`                                                                                                                                          |

All three config types are structurally identical today — each simply extends the same base config. There's no field that exists on one but not the others at the type level, though a couple of fields don't take effect in every mode (e.g. `promoTicker` is accepted by `ElementsCheckout()`'s config type, but the checkout-only client has no cart drawer to render a ticker in).

```js
import { Elements } from '@liquidcommerce/elements-sdk';

const client = await Elements('YOUR_API_KEY', {
  env: 'production',
  // ...any fields below
});
```

* **`apiKey`** (first positional argument, all three factories) — required, non-empty string. An empty or whitespace-only key throws a catchable `SDKError` before any network call is made.
* All three factories resolve to `null` (never reject) if called outside a browser, or if initialization itself fails (bad key, auth error). See [Overview → Initialization modes](https://docs.liquidcommerce.cloud/elements-v2/overview.md#initialization-modes).
* Calling the **same** factory twice with an identical `apiKey`/`env`/`debugMode`/`development.mockMode` returns the same underlying client instance rather than re-initializing from scratch.
* `Elements()`, `ElementsBuilder()`, and `ElementsCheckout()` calls must be **awaited sequentially** — starting a second call before the first one's promise resolves throws, even across different factory functions.

## The config object

```ts
interface ILiquidCommerceElementsConfig {
  env?: ElementsEnv;                                        // 'staging' | 'production'
  promoTicker?: IPromoTicker[];
  customTheme?: IClientCustomThemeConfig;
  debugMode?: DebugMode;                                     // 'none' | 'console' | 'panel'
  checkout?: ILiquidCommerceElementsCheckoutConfig;          // { pageUrl?: string }
  proxy?: IElementsProxyConfig;                              // { baseUrl: string; headers?: Record<string, string> }
  development?: ILiquidCommerceElementsDevelopmentConfig;    // { customApiUrl?; openShadowDom?; mockMode? }
}
```

| Field         | Type                                       | Default                                  | See                         |
| ------------- | ------------------------------------------ | ---------------------------------------- | --------------------------- |
| `env`         | `ElementsEnv`                              | `'production'`                           | [env](#env)                 |
| `promoTicker` | `IPromoTicker[]`                           | `null`                                   | [promoTicker](#promoticker) |
| `customTheme` | `IClientCustomThemeConfig`                 | `null`                                   | [customTheme](#customtheme) |
| `debugMode`   | `DebugMode`                                | `'none'`                                 | [debugMode](#debugmode)     |
| `checkout`    | `ILiquidCommerceElementsCheckoutConfig`    | `null`                                   | [checkout](#checkout)       |
| `proxy`       | `IElementsProxyConfig`                     | `null`                                   | [proxy](#proxy)             |
| `development` | `ILiquidCommerceElementsDevelopmentConfig` | — (each sub-field defaults individually) | [development](#development) |

Every field is optional; an empty object (or omitting `config` entirely) is a valid call.

## `env`

`'staging' | 'production'` — selects which backend the client talks to. Default is `'production'`; any other value logs a console warning and is reset to `'production'`.

| `env`        | API base URL                                                            |
| ------------ | ----------------------------------------------------------------------- |
| `staging`    | `https://elements-services-staging-948630220003.us-central1.run.app`    |
| `production` | `https://elements-services-production-948630220003.us-central1.run.app` |

`development.customApiUrl` (below) overrides this entirely, regardless of `env`. Note these are the SDK's internal API hosts, not the CDN hosts that serve the SDK script itself — see [Overview](https://docs.liquidcommerce.cloud/elements-v2/overview.md) for CDN URLs.

## `promoTicker`

```ts
interface IPromoTicker {
  promoCode: string;    // promo code to auto-apply
  text: string[];       // messages to rotate through
  separator: string;    // separator shown between messages
  activeFrom: string;   // ISO 8601 date string
  activeUntil: string;  // ISO 8601 date string, must be later than activeFrom
}
```

An array of promo ticker configs for the cart drawer's scrolling ticker. Default is `null`. Each entry is validated independently — a non-empty `promoCode`, a non-empty array of non-empty `text` strings, a non-empty `separator`, and valid `activeFrom`/`activeUntil` dates with `activeFrom` earlier than `activeUntil`. Entries that fail validation are dropped (with a console warning) rather than rejecting the whole array; if none remain valid, `promoTicker` becomes `null`.

Full behavior, example, and how this relates to the single-entry `data-promo-*` script attributes: see [Advanced → Promo Ticker](https://docs.liquidcommerce.cloud/elements-v2/advanced.md#promo-ticker).

## `customTheme`

```ts
interface IClientCustomThemeConfig {
  global?: UpdateComponentGlobalConfigs;    // DeepPartial<IComponentGlobalConfigs>
  product?: UpdateProductComponent;         // DeepPartial<IProductComponent>
  address?: UpdateAddressComponent;         // DeepPartial<IAddressComponent>
  cart?: UpdateCartComponent;               // DeepPartial<ICartComponent>
  checkout?: UpdateCheckoutComponent;       // DeepPartial<ICheckoutComponent>
  productList?: UpdateProductListComponent; // hand-shaped, see below
}
```

Overrides the theme LiquidCommerce has configured for your account server-side. Every key is optional and deep-partial — set only the values you want to change; everything else falls back to the server default. Default is `null` (no override).

| Key           | Applies to                                                                        | Shape                                           |
| ------------- | --------------------------------------------------------------------------------- | ----------------------------------------------- |
| `global`      | Colors, fonts, corner radius, and global layout toggles shared by every component | `theme` + `layout`                              |
| `product`     | The product component                                                             | `theme` + `layout`                              |
| `address`     | The address component                                                             | `theme` only (no `layout`)                      |
| `cart`        | The cart drawer                                                                   | `theme` + `layout`                              |
| `checkout`    | The checkout drawer/page                                                          | `theme` + `layout`                              |
| `productList` | Product List grids                                                                | `theme` + `layout.lists` (keyed by list `slug`) |

All `Update*Component` types are a `DeepPartial` of the corresponding full component interface, **except** `UpdateProductListComponent`, which is hand-shaped because `layout.lists` is a `Record<slug, DeepPartial<IPLCList>>` rather than a deep-partial array — each key targets one product list by its `slug`, and lists you don't mention are left untouched.

`global.layout.showPoweredBy` is the one field that can never be set through `customTheme` — it's a paid-plan gate, and its server value is restored immediately after any merge.

For the exact fields inside every `theme`/`layout` block, what each one visually affects, and copy-paste examples per component: see [**Theming**](https://docs.liquidcommerce.cloud/elements-v2/theming.md). To deliver `customTheme` via the CDN auto-init script instead of a JS object, see [Quick Start Guide → Custom theme config](https://docs.liquidcommerce.cloud/elements-v2/quick-start-guide.md#custom-theme-config).

## `debugMode`

`'none' | 'console' | 'panel'` — controls extra SDK-internal logging. Default is `'none'`; an invalid value logs a warning and resets to `'none'`.

| Value     | Effect                                            |
| --------- | ------------------------------------------------- |
| `none`    | No extra logging.                                 |
| `console` | Verbose console logging of internal SDK activity. |
| `panel`   | Same as `console`, plus an on-page debug panel.   |

> **`console`/`panel` output only ever appears outside `production`.** Regardless of what you pass, the SDK gates its debug logging and panel rendering behind "not production" — so `{ env: 'production', debugMode: 'console' }` produces no extra output. Use `env: 'staging'` to actually see it.

## `checkout`

```ts
interface ILiquidCommerceElementsCheckoutConfig {
  pageUrl?: string; // include "{token}" as a placeholder for the checkout token
}
```

When `pageUrl` is set, the cart's "go to checkout" action redirects to this URL (with `{token}` replaced by the checkout token) instead of opening the checkout drawer inline. Default is `null`.

* If `pageUrl` is omitted, not a string, or empty, the entire `checkout` config is dropped (becomes `null`).
* If `pageUrl` is set but doesn't contain the literal `{token}` placeholder, it's kept as-is but logs a console warning, since the redirect URL won't carry a checkout token.

Full setup (hosted checkout page, reading the token back out): see [Checkout → Hosted checkout (inject)](https://docs.liquidcommerce.cloud/elements-v2/checkout.md#hosted-checkout-inject).

## `proxy`

```ts
interface IElementsProxyConfig {
  baseUrl: string;                     // required
  headers?: Record<string, string>;    // optional, merged into every proxied request
}
```

Routes the SDK's API traffic through a server you control instead of calling the LiquidCommerce API directly. Default is `null`. If `baseUrl` is missing or not a string, the entire `proxy` config is dropped. There is no declarative (`data-*` attribute) equivalent — `proxy` can only be set programmatically, including from the CDN build (e.g. `window.LiquidCommerce.Elements('YOUR_API_KEY', { proxy: { baseUrl: '...' } })`).

Full behavior and a working Express example: see [Advanced → Proxy Setup](https://docs.liquidcommerce.cloud/elements-v2/advanced.md#proxy-setup).

## `development`

```ts
interface ILiquidCommerceElementsDevelopmentConfig {
  customApiUrl?: string;
  openShadowDom?: boolean;
  mockMode?: boolean;
}
```

Host-only options for local testing and debugging.

| Field           | Type      | Default                                 | Description                                                                                                                             |
| --------------- | --------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `customApiUrl`  | `string`  | — (falls back to the `env`-derived URL) | Overrides the API base URL entirely, for local or custom backends. Also disables built-in telemetry regardless of `env`.                |
| `openShadowDom` | `boolean` | `false`                                 | Use an inspectable (open) Shadow DOM instead of the default closed mode. **Forced to `false` in `production`** no matter what's passed. |
| `mockMode`      | `boolean` | `false`                                 | Sends an `X-Liquid-Api-Mock-Mode` header with every API request so the backend returns mock data instead of live data.                  |

> To pre-select a payment method and skip the card form (in any environment), use `actions.checkout.setSavedPaymentMethod` instead of a `development` flag — there is no mock-payment option here.

Task-oriented guidance and the equivalent `data-liquid-commerce-elements-development` JSON script tag: see [Advanced → Development Config](https://docs.liquidcommerce.cloud/elements-v2/advanced.md#development-config) and [Quick Start Guide → Development config](https://docs.liquidcommerce.cloud/elements-v2/quick-start-guide.md#development-config).

## Declarative (script-tag) configuration

The CDN auto-init script reads an equivalent configuration from `data-*` attributes on the `<script data-liquid-commerce-elements>` tag (plus a few JSON `<script>` tags for the object-shaped fields above: `customTheme` and `development`). It supports everything from `env` and `debugMode` to product injection, cart button placement, and query-param handling.

See the [Quick Start Guide](https://docs.liquidcommerce.cloud/elements-v2/quick-start-guide.md) for the complete attribute reference.

## TypeScript

Every interface on this page — plus `DeepPartial<T>`, the utility type the `Update*Component` theme types are built from — is exported from the package root:

```ts
import type {
  ILiquidCommerceElementsConfig,
  ILiquidCommerceElementsBuilderConfig,
  ILiquidCommerceElementsCheckoutClientConfig,
  IClientCustomThemeConfig,
  IPromoTicker,
  IElementsProxyConfig,
  ILiquidCommerceElementsDevelopmentConfig,
  DeepPartial,
} from '@liquidcommerce/elements-sdk';
```

The `/checkout` subpath is a tree-shaken build that re-exports a smaller surface than the package root. The config-relevant exports are `ILiquidCommerceElementsCheckoutClientConfig` plus the `DebugMode` and `ElementsEnv` enums (it also re-exports the checkout client/action/component types documented on other pages):

```ts
import type { ILiquidCommerceElementsCheckoutClientConfig } from '@liquidcommerce/elements-sdk/checkout';
```
