Skip to content

optionsSubstore

Manages lazy-fetched option resources. Each key in the registry corresponds to a distinct SDK option (e.g., "priceForm") fetched from the API on first access and cached for subsequent reads.

Table of contents


getOption

getOption: <T extends keyof typeof optionsRegistry>(
optionKey: T,
) => ApiResource<z.infer<(typeof optionsRegistry)[T]["schema"]>>

Retrieves an option resource by key, lazily fetching from the API on first access.

On the first call for a given key the SDK fires a background request. Subsequent calls return the cached ApiResource immediately. The returned object always reflects the current loading/error state so it is safe to read during render.

Parameters

NameTypeDescription
optionKeykeyof typeof optionsRegistryThe registry key identifying which option to fetch (e.g., "priceForm")

Returns ApiResource<T>data is undefined while loading, then holds the typed option payload once resolved.

Related