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 ofloadThemeSettings() under the weaverseTheme key in the root loader:
weaverseTheme.theme, while the translation provider also uses staticContent and merchantOverrides from this response.
Usage
Export the wrapped component as the root routeLayout:
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:What It Provides
withWeaverse mounts:
ThemeSettingsStoreContextTranslationProviderStudioConnect
WeaverseContext. That runtime context is created by WeaverseHydrogenRoot when it renders a page.
Related
- WeaverseHydrogenRoot - Render the Weaverse page runtime
- useThemeSettings - Read global theme settings
- WeaverseClient - Load root theme settings