Skip to main content

WeaverseClient

WeaverseClient loads Weaverse page data, theme settings, and custom page metadata on the server. It also runs registered component loaders and integrates with Hydrogen caching.

Initialization

Create the client in your app load context:
See the Project Structure guide for the complete setup.

Public API

API is the current API version segment ('v1'), not a complete endpoint URL.

Methods

fetchWithCache

Fetch data through Hydrogen’s cache integration:
Use strategy, not the Fetch API cache property, for Hydrogen cache-control options.

loadThemeSettings

The response can contain:
Return the complete response under weaverseTheme from the root loader so withWeaverse can initialize theme and translation stores:
Read settings directly from the response with response.theme.

loadPage

type

Supported PageType values:
  • '*'
  • 'INDEX'
  • 'PRODUCT'
  • 'ALL_PRODUCTS'
  • 'COLLECTION'
  • 'COLLECTION_LIST'
  • 'PAGE'
  • 'BLOG'
  • 'ARTICLE'
  • 'CUSTOM'
When omitted, the content service resolves the page from the request URL and project configuration.

locale

An optional BCP 47 locale override such as en-US, sv-SE, or fr-CA. The value is forwarded unchanged. When omitted, the request uses context.storefront.i18n; loadPage() does not implement its own URL-prefix detection or en-us fallback.

handle

The resource or custom-page handle used with page types such as PRODUCT, COLLECTION, PAGE, BLOG, and ARTICLE.

projectId

Overrides the client’s resolved project ID for this request. Constructor-level projectId can also be a synchronous or asynchronous function for multi-project storefronts.

strategy

A Hydrogen CachingStrategy, for example:

Example

A missing page payload is normalized into a fallback page. null indicates that loading or validation failed; do not treat it as a reliable page-not-found signal.

fetchCustomPages

Fetches published custom-page entries for sitemap and route-generation workflows.

execComponentLoader

Runs the registered loader for one component and attaches its loader data. loadPage() calls this internally.

generateFallbackPage

Creates the page structure used when the content response does not include page data.