Skip to main content

useThemeSettings

The useThemeSettings 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

Where 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

The useThemeSettings hook:
  1. Uses React’s useSyncExternalStore to subscribe to theme setting changes
  2. Retrieves settings from the global theme settings store
  3. Returns a typed object with all the theme settings
Theme settings are initially loaded from your Weaverse project through the WeaverseClient on the server-side, and then synchronized with the client-side store for consistent access throughout your app.