> ## Documentation Index
> Fetch the complete documentation index at: https://weaverse.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Weaverse component configuration uses `settings`. `inspector` is deprecated; never generate it.
> Weaverse Hydrogen themes use React Router v7: import from `react-router`, never `react-router-dom` or `@remix-run/*`.
> Before using any code sample, read `@weaverse/hydrogen` in the project's `package.json`: 6.x and 5.x import from different entries and use different type names, so code for one does not build on the other.
> `@weaverse/hydrogen` 6 (Shopify Hydrogen 2026.10 and later, the version these docs show) imports from `@weaverse/hydrogen/react-router` and uses `Weaverse*` types such as `WeaverseComponentProps`, `WeaverseComponentLoaderArgs` and `WeaverseComponentSchema`; the root `@weaverse/hydrogen` entry only exports `createSchema()`, data helpers and types.
> `@weaverse/hydrogen` 5.x (Hydrogen 2026.4 and earlier) imports everything from `@weaverse/hydrogen` and uses `HydrogenComponentProps`, `ComponentLoaderArgs` and `HydrogenComponentSchema`. On a 5.x project, convert samples to these names. Upgrade to 6 only when asked (`npx @weaverse/cli@latest migrate v6`, plus the Hydrogen 2026.10 upgrade). Do not mix major versions.
> Next.js themes use `@weaverse/hydrogen` 6.2.0 or later: import client and shared code from `@weaverse/hydrogen/next` and server-only code from `@weaverse/hydrogen/next/server`. `@weaverse/next` is deprecated; never install or import it.
> For live project data (pages, theme settings, translations), use the Weaverse MCP server: https://weaverse.io/docs/developer-tools/weaverse-mcp

# WeaverseClientArgs

> Extended WeaverseClient constructor arguments supporting multi-project architecture.

A static project ID:

```ts
const weaverse = new WeaverseClient({
  ...hydrogenContext,
  projectId: 'project-default-123'
})
```

A project ID chosen per request:

```ts
const weaverse = new WeaverseClient({
  ...hydrogenContext,
  projectId: () => {
    const origin = new URL(request.url).origin
    if (origin === 'https://mystore.se') return process.env.WEAVERSE_PROJECT_SWEDEN!
    if (origin === 'https://mystore.fr') return process.env.WEAVERSE_PROJECT_FRANCE!
    return process.env.WEAVERSE_PROJECT_ID!
  }
})
```

**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

**cache** `CacheInstance` *required*

Hydrogen cache instance for content caching, such as the worker's
`caches.open('hydrogen-v1')`. Cache keys include the project ID.

**components** `WeaverseComponent\<any\>[]` *required*

**Type:** `WeaverseComponent<any>[]`

React components registered with Weaverse CMS.
Each component must have a schema defining its properties and settings.

**customerAccount** `unknown`

Customer Account API client, when the storefront has one. Weaverse only
passes it through to section loaders.

**env** `WeaverseEnv` *required*

Runtime environment variables, such as the Oxygen worker `env`.

**fetchTimeoutMs** `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.

```typescript
new WeaverseClient({
  // ... other args
  fetchTimeoutMs: 5000 // 5 second timeout
})
```

**locale** `WeaverseI18n`

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.

**projectId** `ProjectIdValue`

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](https://weaverse.io/docs/api-reference/classes/WeaverseError.md) 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** `Request` *required*

Incoming HTTP request object from React Router loader.
Provides access to URL, headers, cookies for dynamic routing decisions.

**storefront** `WeaverseStorefront` *required*

Request-scoped Hydrogen Storefront API client. Section loaders reach it
as `weaverse.storefront`; its `locale` selects the content locale unless
[WeaverseClientArgs.locale](https://weaverse.io/docs/api-reference/interfaces/WeaverseClientArgs.md#property-locale) is given.

**themeSchema** `WeaverseThemeSchema` *required*

Theme schema defining global theme settings (colors, fonts, layouts).
Used to generate default theme configuration and validate theme data.

**throwPageLoadFailures** `boolean`

Reject `loadPage()` with a [WeaverseLoadError](https://weaverse.io/docs/api-reference/classes/WeaverseLoadError.md) 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.

**waitUntil** `(promise: Promise\<unknown\>) =\> void`

Keeps the runtime alive for background cache writes and refreshes.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.