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 once per request in your app context, from the request’s Hydrogen 2026.10 Storefront API client. Pilot does this in app/.server/context.ts:
createRequestStorefront, createCustomerAccount, AppSession and resolveRequestLocale are app code; see Step 4 of the v6 migration guide. server.ts copies the returned object onto React Router’s context, so loaders read context.weaverse. See the Project Structure guide for the complete setup.

Public API

  • locale selects the content locale, the Translation Manager overrides (${language}-${country}, lowercased) and the locale Studio reads, so include pathPrefix. Pass it when the Storefront client’s i18n.language is a Shopify LanguageCode that differs from the market’s public language, such as ZH_TW for a Traditional Chinese Hong Kong market. Added in @weaverse/hydrogen 6.1.0.
  • throwPageLoadFailures: true makes loadPage() reject with a WeaverseLoadError when the content API is unavailable, instead of resolving to null, so a route can answer an outage differently from a missing page.
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 the client’s locale argument, or storefront.i18n when that isn’t set; 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 (create one with Cache from @shopify/hydrogen), 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.
Last modified on November 10, 2026