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
ReturnweaverseData from the route loader. The component automatically reads the closest route’s loader data:
Passing Data Explicitly
Use thedata prop when a layout and child route render different Weaverse pages on the same URL:
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
weaverseDataresolution. 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
weaverseDatais used whendatais omitted. - Multiple roots are supported for nested layouts and child routes.
data={null}returnsnullwithout rendering an error.- Missing automatically resolved data renders
errorComponent.
Related
- withWeaverse - Set up root theme, translation, and Studio integration
- WeaverseClient - Load page and theme data
- useWeaverse - Access the active runtime