Skip to main content

withWeaverse

withWeaverse wraps the root route Layout with the theme settings store, translation provider, and Studio connection bridge. Use it on Layout, not only on the default route component. React Router keeps Layout mounted around both the matched route and ErrorBoundary, so the Studio connection remains available during loader, render, and 404 errors.

Import

Type

Root Loader Requirement

Return the result of loadThemeSettings() under the weaverseTheme key in the root loader:
The theme store reads weaverseTheme.theme, while the translation provider also uses staticContent and merchantOverrides from this response.

Usage

Export the wrapped component as the root route Layout:
Do not wrap the default route component and ErrorBoundary separately. When an error occurs, React Router replaces the default component but keeps Layout mounted.

External Translation Function

Pass a translation function through the optional second argument when integrating another i18n system:
The provided function has the highest priority in the translation resolution chain.

What It Provides

withWeaverse mounts:
  • ThemeSettingsStoreContext
  • TranslationProvider
  • StudioConnect
It does not create the page-level WeaverseContext. That runtime context is created by WeaverseHydrogenRoot when it renders a page.