Skip to main content

WeaverseHydrogenRoot

WeaverseHydrogenRoot is the public Hydrogen renderer. It resolves weaverseData from the current React Router route, creates the Weaverse runtime, registers your theme components, and renders the page tree.

Import

The lower-level WeaverseRoot component belongs to @weaverse/react and requires an initialized Weaverse runtime. Hydrogen applications should use WeaverseHydrogenRoot instead.

Type

Basic Usage

Return weaverseData from the route loader. The component automatically reads the closest route’s loader data:

Passing Data Explicitly

Use the data prop when a layout and child route render different Weaverse pages on the same URL:
The data prop accepts a resolved value or a promise. Passing null explicitly suppresses rendering.

Props

components

  • Type: HydrogenComponent[]
  • Required: Yes
  • Description: Component definitions available to the page renderer.

data

  • Type: WeaverseLoaderData | Promise<WeaverseLoaderData | null> | null
  • Required: No
  • Description: Overrides automatic route-scoped weaverseData resolution. Promises are handled with React Router’s <Await>.

errorComponent

  • Type: React.FC<{ error: Error | unknown }>
  • Required: No
  • Description: Rendered when page data cannot be resolved or rendering throws.

Behavior

  • The closest route’s weaverseData is used when data is omitted.
  • Multiple roots are supported for nested layouts and child routes.
  • data={null} returns null without rendering an error.
  • Missing automatically resolved data renders errorComponent.