useWeaverse
TheuseWeaverse
hook provides access to the global Weaverse instance, giving components access to page data, component registry, theme settings, and other essential Weaverse functionality. It serves as the main entry point for interacting with the Weaverse system.
Import
Type
Returns
WeaverseInstance
- The Weaverse instance containing global state and methods
Common Use Patterns
Accessing Global Theme Settings
Get access to global theme settings that apply across the entire storefront:Accessing Component Registry
Look up specific component instances from anywhere in your application:Accessing Page Data
Get access to the current page’s data structure:Global Event Handling
Listen to and dispatch global events across the Weaverse ecosystem:Core Properties
themeSettings
- Type:
HydrogenThemeSettings
- Description: Global theme settings like colors, typography, and layout options
itemInstances
- Type:
Map<string, WeaverseItemStore>
- Description: Registry of all component instances available in the current page
page
- Type:
WeaversePage
- Description: Current page data including type, handle, and sections
eventBus
- Type:
EventBus
- Description: Publish-subscribe system for cross-component communication
elementRegistry
- Type:
Map<string, HTMLElement>
- Description: Registry mapping component IDs to their DOM elements
When To Use
- When you need to access global theme settings
- When you need to find and interact with components that aren’t in the current component tree
- When implementing global state management or event handling
- When you need access to page-level configuration data
Related
- useItemInstance - Access a specific component instance
- useParentInstance - Access the parent component instance
- useChildInstances - Access child component instances
- useThemeSettings - Access theme settings