Skip to content

ContentClientOptions

@ebitex/content-sdk — the framework-agnostic half.

  • Low-level: createDeliveryClient — one method per Content Delivery API endpoint, the delivered vocabulary as types (types.ts) and runtime guards (guards.ts), typed errors.
  • High-level: createContentClient — resolveLocation(location) for router changes: site from the page’s own host, locale from the browser’s languages against the organization’s tree, the context bag, a full/normalized resolve strategy, caching and cancellation.

Nothing here imports React; the rendering layer is @ebitex/content-sdk/react. Both clients run in a browser (with a browser-safe delivery key) and in Node (any key).

apiKey: string

A Content delivery key, created on the Content app’s Delivery page. A key with an allowed-origins or allowed-IP-ranges restriction is browser-safe and may ship in a bundle; a key with neither is a server-side key and must never reach a browser — it works from any origin and any address. The SDK cannot tell the two apart; only the Delivery page can, so decide where this client runs before choosing a key.

DeliveryClientOptions.apiKey


optional audience?: AudienceOptions

Turn on audience-aware delivery. With this set, the client obtains the visitor’s signed audience token from Audience, sends it with every read that depends on it, renews it before it expires or when something may have changed (a Forms submission, the tab becoming visible again after a pause), keeps a separate cache for each set of audiences the visitor holds, and re-renders the React tree when that set changes. You supply an Audience delivery key and, optionally, what the page knows about the visit; you never handle a token. Without it nothing changes: a variant on an audience is simply not delivered, as for a visitor in no audience. A failure of Audience never stops a page rendering.


optional baseUrl?: string

Defaults to ebitex’s production API. Override for a self-hosted or local deployment.

DeliveryClientOptions.baseUrl


optional cache?: false | CacheOptions

In-memory cache of resolved results (default 50 entries, LRU); false disables it.


optional context?: ContextBag | (() => ContextBag | Promise<ContextBag>)

The personalization context bag, or a (possibly async) function producing it per resolve. Always sent — {} by default — so the server resolves personalization and tokens. Audiences are not part of it: see audience.


optional env?: string

The delivery environment id, known ahead of time (e.g. a build-time constant) — sent as env= on the very first /sites//locales request of the session, not only on requests made after a live /sites response has revealed it. Doesn’t suppress either call (both still fire on every load) — it only lets them carry env= sooner, which is what makes them edge-cache-eligible from a session’s first request rather than only its second.


optional fetch?: {(input, init?): Promise<Response>; (input, init?): Promise<Response>; }

Injectable for testing or for a runtime with a non-global fetch.

(input, init?): Promise<Response>

MDN Reference

URL | RequestInfo

RequestInit

Promise<Response>

(input, init?): Promise<Response>

MDN Reference

string | URL | Request

RequestInit

Promise<Response>

DeliveryClientOptions.fetch


optional locale?: string | ((locales) => string | undefined)

The locale code to request: a string, or a function choosing from GET /locales. Omitted: the first of the browser’s languages (each region tag followed by its base language) present in the organization’s locale tree; nothing in Node, or when none matches (the server’s default).


optional onAudienceStatus?: (status) => void

Called when a response carries X-Ebitex-Audiences-Status: expired | invalid: the audience token this client sent is no longer good, and the caller should obtain a fresh one. The high-level client wires this to its audience session; a direct user of this client may ignore it.

"expired" | "invalid"

void

DeliveryClientOptions.onAudienceStatus


optional onSandbox?: (mode) => void

Called when the mode the API reports for this organization changes: development or cutover while it is a sandbox an agency is building for a client, null once it is an ordinary organization (or if it never was). Read it off any response, so the first call after the organization goes live is the one that clears it.

SandboxMode | null

void

DeliveryClientOptions.onSandbox


optional referencePaths?: boolean

Ask every read to attach each reference descriptor’s own published address(es) (paths), so a document that references another page can link to it with no second query. Off by default; with it off, responses and persisted cache keys are unaffected.

Deliberately a client-level option rather than a per-call one: the resolved shape is part of the cache key, so a per-call flag would split two callers resolving the same location into two requests. A site either wants linkable references or does not.


optional resolve?: ResolveStrategy

Default { strategy: 'adaptive' } — full for the first location this client instance resolves (and every later resolve of it), normalized (depth 1) for any other. In Node, always full: normalized trades depth for on-demand fetches that only a browser can make, and one server-side client instance serves every path for the life of the process.


optional site?: string | ((sites) => SiteSummary | undefined)

The site to resolve paths against: a rootNodeId, or a function choosing from GET /sites. Omitted: the sole published site, else the one whose hosts contains this page’s hostname. Required in Node when more than one site is published.