Skip to main content

useWeaverse

The useWeaverse hook returns the active Weaverse runtime. In Hydrogen themes, use the WeaverseHydrogen generic when you need Hydrogen-specific page data and runtime properties.

Import

Type

Returns

  • T — The active Weaverse runtime. It defaults to the core Weaverse type.

Common Use Patterns

Accessing Component Instances

The itemInstances registry maps component instance IDs to their item stores:

Accessing Page Data

Specify WeaverseHydrogen to get the Hydrogen page data type:

Core Properties

itemInstances

Registry mapping component instance IDs to their item stores.

data

The current project data. For WeaverseHydrogen, this is HydrogenPageData, which includes the page ID, name, root ID, and component items.

elementRegistry

Registry mapping component types to their registered component definitions. It is not a registry of DOM elements or component instance IDs.

When To Use

  • When you need to find and interact with components outside the current component tree
  • When you need access to page-level runtime data