Skip to main content
Create one client from the Hydrogen app context, then call WeaverseClient.loadPage from route loaders and WeaverseClient.loadThemeSettings from the root loader. Also runs registered component loaders and routes Builder API requests through Hydrogen’s cache. API is the API version segment ('v1'), not a complete endpoint URL. The constructor checks the project ID, whatever throwPageLoadFailures is set to: it throws a WeaverseError with code MISSING_PROJECT_ID when none resolves (?weaverseProjectId=, the projectId argument or WEAVERSE_PROJECT_ID), INVALID_PROJECT_ID for a malformed projectId, and ASYNC_PROJECT_ID for an async projectId function, which must be awaited before you create the client. Create the client once per request in the app context, from the request’s Hydrogen 2026.10 Storefront API client. createRequestStorefront, createCustomerAccount, AppSession and resolveRequestLocale are app code (see the v6 migration guide); server.ts copies the returned object onto React Router’s context, so loaders read context.weaverse.

Constructor

Creates a request-scoped client from the storefront’s request context.

Parameters

Returns

WeaverseClient

Properties

"v1"
required
Builder API version used by this client.
Omit<WeaverseProjectConfigs, "requestInfo">
required
Type: WeaverseProjectConfigsStable project configuration shared by page requests.
Omit<FetchProjectRequestBody, "url">
required
Type: FetchProjectRequestBodyStable request body fields shared by page requests.
CacheInstance
required
Cache storage supplied by the Hydrogen runtime.
WeaverseComponent<any>[]
required
Type: WeaverseComponentComponents registered for page rendering and component loaders.
Resolved project and rendering-mode configuration.
unknown
required
Customer Account API client, when the storefront passes one.
required
Runtime environment variables.
Request
required
Incoming request associated with this client instance.
Hydrogen Storefront API client and locale context.
Theme schema used for defaults and Studio editing.
(promise: Promise<unknown>) => void | undefined
required
Background execution hook supplied by the runtime.

Methods

execComponentLoader()

Executes the registered loader for one component and attaches its result.

Parameters

Returns

WeaverseComponentData

fetchCustomPages()

Fetch the route metadata of every custom page assigned in the project (path, lastModified, changeFrequency, priority, plus locale, market and scope, which tell global, locale and market assignments apart), for sitemap and route generation. Paginates automatically. Rejects with a WeaverseLoadError when any page of results cannot be loaded, so a sitemap route can answer 5xx instead of serving a partial or empty sitemap that search engines cache. The list is not filtered by publication state, so an entry is not proof that the page is published. Apply your own publication policy before you add a route to a public sitemap.

Parameters

Returns

CustomPageEntry

fetchWithCache()

Fetch data with caching support for both design mode and production. Uses direct fetch in design mode, Hydrogen’s cached fetch in production. Automatically includes projectId in cache key for multi-project isolation. Pass Hydrogen cache-control options as strategy, not the Fetch API cache property. Hydrogen’s cache is skipped in design mode, in revision preview, and for requests to the Weaverse public API proxy (https://api.weaverse.io/api/public/... by default). The proxy owns the freshness of Weaverse data, so strategy applies to third-party URLs and to a self-hosted WEAVERSE_HOST that serves the API itself.

Parameters

string
required
The URL to fetch from
Fetch options including optional cache strategy

Returns

Promise<T> Promise resolving to the fetched data

generateFallbackPage()

Generate fallback page with default structure when page data is unavailable. Used internally when API returns no page or when page needs default content.

Parameters

string
required
Custom message to display in the fallback page

Returns

WeaversePageData WeaversePageData with single main component containing the message

loadPage()

Load page data from Weaverse API with optional route-level project override. Fetches page content, executes component loaders, and handles empty items fallback. What loadPage() resolves to:
  • A page when one is assigned to the route.
  • A fallback page with isFallback: true when the project loads but no page is assigned to the route. It is not null. Answer it with a 404 on the live storefront, but keep it in design mode, where the merchant builds on it in Studio.
  • null when the Weaverse API answers 404 (for example, the project does not exist), and, by default, when the load fails (invalid per-call projectId, network error, timeout, error status or error body). The failure is logged.
  • The fallback page, by default, when the API answers 200 with a body that is not a page envelope (for example {}).
  • A rejection with a WeaverseLoadError instead of null for a failed load when the client sets throwPageLoadFailures: true.
locale is forwarded unchanged; when omitted, the request uses the client’s locale argument, or storefront.locale. strategy takes effect only when the page request goes through Hydrogen’s cache: requests to the default Weaverse public API proxy skip it.
Answer a missing page with a 404:

Parameters

Optional page loading parameters

Returns

WeaverseLoaderData Promise resolving to page data or null on error

loadThemeSettings()

Load theme settings from Weaverse API with fallback to schema defaults. Merges remote settings with local theme schema and handles design mode serialization. Return the whole response under weaverseTheme from the root loader so withWeaverse can initialize the theme settings and translation stores. Read setting values from response.theme.

Parameters

CachingStrategy
Optional cache strategy override

Returns

WeaverseThemeSettingsResponse Promise resolving to theme settings response