Skip to main content
Higher-order component that wraps your app with Weaverse theme settings and translation context, and mounts the Studio connect bridge. Export the result as your root route’s Layout (not the default route Component). In React Router the root Layout wraps both the matched route and its ErrorBoundary, so the Studio bridge keeps rendering on 404s and loader/render errors — exactly the pages where Studio must still answer its handshake instead of reporting a false “Connection lost”. A default-component wrapper (export default withWeaverse(App)) is replaced by the error boundary on those routes and would drop the bridge. The root loader must return the result of WeaverseClient.loadThemeSettings under the weaverseTheme key: the theme store reads weaverseTheme.theme and the translation provider reads staticContent and merchantOverrides. withWeaverse does not create the page-level Weaverse runtime; WeaverseHydrogenRoot does.
Pass an external translation function, which takes the highest priority in t():

Parameters

ComponentType<any>
required
The root layout component to wrap
Optional configuration (e.g. an external t function)

Returns

(props: IntrinsicAttributes) => Element Wrapped component with theme settings + translation providers