Wocart

@wocart/storefront v3.1.0


@wocart/storefront / index / StoreScope

Interface: StoreScope

The scope of one Store Client. A client is never a cross-store client: its API key selects exactly one store and its caches live inside that client. This type is exported from the browser-safe barrel for type reuse only; the API key must still be supplied and retained by server-side code.

Properties

apiKey

readonly apiKey: string


locale?

readonly optional locale?: string

The language this client reads merchant text in (BCP 47, e.g. fr) — Shopify Hydrogen's per-request i18n. The server serves it when the store publishes it and the primary otherwise; StoreConfig.locale says which. Untranslated fields fall back to the primary one by one. Create one client per language: each keeps its own caches. Omit it for the primary.


onError?

optional onError?: (error) => void

Opt-in degradation hook. Reads resolve to null/[]/{} when a call cannot be completed — that is the theme-facing contract and it does not change. But "the network is down" and "the server's response no longer matches the SDK's schemas" must not look identical to the operator, and a degraded read is the one failure a theme never sees. Every swallowed failure is reported here, carrying the same DomainError a mutation returns (code, operation, requestId, retryable). Never called on success.

Parameters

error

DomainError

Returns

void


readTimeoutMs?

readonly optional readTimeoutMs?: number

How long one read may take, retries included, before it gives up: the read then degrades like any other failed read and onError receives a REQUEST_TIMEOUT. A server that stops answering costs a page this long instead of holding it open. Defaults to 10 000 ms; 0 removes the limit. Writes have no default limit: a write cut off by a timer may already have happened, and retrying it could place the same order twice.


serverUrl

readonly serverUrl: string


theme?

readonly optional theme?: string

The key of the theme this client renders (defineTheme({ key }) in @wocart/theme). The store's edits to that theme's text arrive as StoreConfig.contentOverrides; without it there are none, because edits belong to the theme that declares their keys. pageData.get reads the documents the store composed for that theme. The server owns the key format and refuses a malformed one.