Skip to main content
A static project ID:
A project ID chosen per request:
Priority Chain (highest to lowest):
  1. URL query parameter: ?weaverseProjectId=... (design mode, preview mode)
  2. Function result (if function provided)
  3. Explicit string value (if string provided)
  4. Environment variable: WEAVERSE_PROJECT_ID (Hydrogen env or process.env)
  5. Empty string (triggers validation error in methods)
Function Requirements:
  • Must return non-empty string
  • Can access request via closure for routing decisions
  • Evaluated once per WeaverseClient instance (request-scoped)
  • Async functions must be awaited before passing to constructor
  • Should handle edge cases (missing headers, invalid domains, etc.)
Request Context Access: Functions access request via closure from constructor arguments.

Properties

CacheInstance
required
Hydrogen cache instance for content caching, such as the worker’s caches.open('hydrogen-v1'). Cache keys include the project ID.
WeaverseComponent<any>[]
required
Type: WeaverseComponentReact components registered with Weaverse CMS. Each component must have a schema defining its properties and settings.
unknown
Customer Account API client, when the storefront has one. Weaverse only passes it through to section loaders.
required
Runtime environment variables, such as the Oxygen worker env.
number
Fetch timeout in milliseconds for API requests. Defaults to 10000ms (10 seconds) if not specified. Useful for adjusting based on network conditions or deployment environment.
The market this request serves, as Weaverse identifies it. It selects the Translation Manager overrides (${language}-${country}, lowercased), the locale sent with page requests and the requestInfo.i18n Studio reads, so include pathPrefix. Pass it when the storefront’s locale.language is a Shopify LanguageCode that differs from the market’s public language, such as ZH_TW for a Traditional Chinese Hong Kong market.
Project identifier for loading content from Weaverse CMS.Value Types:
  • Static string: ‘project-123’ (existing usage)
  • Synchronous function: () => determineProject(request)
An async function, or one that returns a promise, makes the constructor throw a WeaverseError with code ASYNC_PROJECT_ID, even though the type lists () => Promise<string>: resolve the ID first and pass the result, for example projectId: await resolveProjectId(request). When no project ID resolves (?weaverseProjectId=, this argument or WEAVERSE_PROJECT_ID), the constructor throws MISSING_PROJECT_ID; a malformed value throws INVALID_PROJECT_ID. Both happen whatever throwPageLoadFailures is set to.Backward Compatibility:
  • Optional parameter (defaults to environment variable)
  • Existing code without projectId continues to work unchanged
Cache Isolation: ProjectId is included in cache keys to prevent cross-project content pollution. Each project’s content is cached separately, ensuring multi-tenant isolation.
Request
required
Incoming HTTP request object from React Router loader. Provides access to URL, headers, cookies for dynamic routing decisions.
Request-scoped Hydrogen Storefront API client. Section loaders reach it as weaverse.storefront; its locale selects the content locale unless WeaverseClientArgs.locale is given.
Theme schema defining global theme settings (colors, fonts, layouts). Used to generate default theme configuration and validate theme data.
boolean
Reject loadPage() with a WeaverseLoadError when the page cannot be loaded, instead of resolving to null.With the default (false), an unavailable API, an invalid response and a configuration failure all resolve to null, the same value a missing project produces, so a route cannot tell an outage from a 404. Enable this to answer failures with a retryable or configuration error response while genuine absence keeps resolving to null or a fallback page.
(promise: Promise<unknown>) => void
Keeps the runtime alive for background cache writes and refreshes.