useThemeSettings
TheuseThemeSettings
hook provides access to the global theme settings within a Weaverse Hydrogen theme, enabling components to adapt to merchant-configured preferences set in Weaverse Studio.
Import
Type
HydrogenThemeSettings
is a flexible object type that contains all your theme’s global settings.
Usage
Call the hook within a React component to get an object containing the current global theme settings:Basic example
With TypeScript for type safety
Conditional rendering based on theme settings
How It Works
TheuseThemeSettings
hook:
- Uses React’s
useSyncExternalStore
to subscribe to theme setting changes - Retrieves settings from the global theme settings store
- Returns a typed object with all the theme settings
WeaverseClient
on the server-side, and then synchronized with the client-side store for consistent access throughout your app.
Related
- withWeaverse - HOC that sets up the theme settings provider
- Global Theme Settings - Guide to configuring global theme settings
- WeaverseHydrogenRoot - Main component that initializes Weaverse