Documentation Index
Fetch the complete documentation index at: https://docs.weaverse.io/llms.txt
Use this file to discover all available pages before exploring further.
WeaverseRoot
TheWeaverseRoot component is the primary renderer for Weaverse content in React applications. It serves as the entry point for rendering dynamic, data-driven Weaverse components based on the provided Weaverse context.
Import
Props
| Prop | Type | Description |
|---|---|---|
context | Weaverse | The Weaverse instance containing the project data and component registry. |
Type Definition
Usage
How It Works
TheWeaverseRoot component:
- Creates a React context provider that makes the Weaverse instance available throughout the component tree
- Renders the root component from the Weaverse project data
- Sets up the necessary DOM structure with data attributes for Weaverse Studio integration
- Establishes the component tree based on parent-child relationships defined in the project data
- Passes appropriate props and data to each component in the tree
Rendering Process
- The component subscribes to changes in the Weaverse instance using
useSyncExternalStore - It renders a container element with appropriate Weaverse data attributes
- It finds the root component ID from the Weaverse data
- It recursively renders each component in the tree using internal
ItemInstanceandItemComponentcomponents - Each component receives its data and children components based on the Weaverse project structure
Example: Full Page Structure
Notes
- Only one
WeaverseRootcomponent should be used per page - The component automatically handles the entire component tree rendering
- No need to manually render children - the component handles parent-child relationships
- The component adds necessary data attributes for Weaverse Studio integration
- Returns
nullif no valid Weaverse context or project ID is provided
Related
- useWeaverse - Hook to access the Weaverse instance
- WeaverseHydrogenRoot - Hydrogen-specific wrapper around WeaverseRoot
- useItemInstance - Access component instances in the tree