Weaverse v5 runs on React Router v7, aligning with Shopify Hydrogen’s React Router migration. See the current Hydrogen updates, then pick the version that matches your Hydrogen setup:
- Hydrogen on React Router v7 (2025.5.0 and newer): use
@weaverse/hydrogen@5(latest) - Hydrogen on Remix (older releases): use
@weaverse/hydrogen@4(legacy)
package.json for react-router vs @remix-run/react.Prerequisites
Before you start, ensure you have:- An existing Shopify Hydrogen project set up and running locally.
- Node.js 20+ and npm/yarn/pnpm installed.
- Your Hydrogen project connected to your Shopify store.
- A Weaverse account and a Weaverse Project created for your storefront.
- Basic familiarity with Hydrogen concepts and either:
- React Router v7 (Hydrogen 2025.5.0+) — recommended
- Remix (older Hydrogen versions) — legacy support only
Migration Consideration
If you’re currently on Hydrogen with Remix and want to move to React Router v7, review the current Hydrogen updates first, then install Weaverse v5. See also the Weaverse v5 migration guide. Alternatively, stay on Weaverse v4 with your current Remix setup.Step 1: Install Weaverse SDK
Navigate to your Hydrogen project directory in your terminal and add the Weaverse Hydrogen SDK.For Hydrogen with React Router v7 (Recommended)
For Hydrogen with Remix (Legacy — v4)
How to Check Your Hydrogen Version
Check yourpackage.json dependencies:
- React Router v7: contains
react-router,@react-router/dev, and@shopify/hydrogen@2025.5.0+ - Remix: contains
@remix-run/react
Step 2: Configure Environment Variables
Weaverse needs credentials to connect to your project. Add the following variables to your.env file (create one if it doesn’t exist) at the root of your Hydrogen project:
"your-project-id" with the Project ID found in your Weaverse project settings.
Step 3: Set Up Core Weaverse Files
Create aweaverse folder inside your app directory (app/weaverse/). This folder will house Weaverse-specific configurations and utilities.
1. Theme Schema (~/weaverse/schema.server.ts)
This file defines your theme’s metadata (name, author, version), global settings schema (which populates the Theme Customizer in Weaverse Studio), and i18n configuration.
2. Global Styles (~/weaverse/style.tsx)
This component applies global CSS variables based on the theme settings defined in schema.server.ts and configured in Weaverse Studio.
3. Component Registration (~/weaverse/components.ts)
This is the central file where you register all the React components that you want to be available for use within the Weaverse editor.
4. WeaverseContent Component (~/weaverse/index.tsx)
This component renders Weaverse content using WeaverseHydrogenRoot with your registered components. Export a validateWeaverseData helper here too — routes call it to return a 404 when a page has no published Weaverse content.
5. Content Security Policy (CSP) (~/weaverse/csp.ts)
This utility produces the CSP directives required for the Weaverse Studio iframe to work. Note the context type is HydrogenRouterContextProvider from @shopify/hydrogen — not the Remix AppLoadContext.
Step 4: Add the Weaverse Client to Your Hydrogen Context
A crucial step is to initialize the Weaverse client and attach it to your Hydrogen router context. This makescontext.weaverse available in every loader and action.
1. Update Your Context File
In current Hydrogen, the context lives inapp/.server/context.ts and exports createHydrogenRouterContext. createHydrogenContext() returns a RouterContextProvider class instance — spreading it into a plain object would destroy the prototype and break Hydrogen. Attach Weaverse with Object.assign and return the original instance:
- Imports
WeaverseClientfrom the Weaverse Hydrogen SDK - Imports your theme schema and components from the files created in the previous step
- Initializes a
WeaverseClientwith the Hydrogen context, request, and cache - Attaches the client to the existing context instance, exposing it as
context.weaverse
2. Ensure Your Server Entry Uses the Context
Yourserver.ts should build the context and hand it to the request handler:
The virtual module is still named
virtual:react-router/server-build — the remixBuild identifier in Pilot is just a variable name, not a Remix import.Step 5: Integrate Weaverse into Your Application
Now, let’s modify your existing Hydrogen files to enable Weaverse.1. Update CSP in entry.server.tsx
Spread getWeaverseCsp() into createContentSecurityPolicy(). On React Router v7 the entry renders ServerRouter (not RemixServer) and the context parameter is typed as HydrogenRouterContextProvider:
2. Update the Root Route
Weaverse needs to wrap the component that renders the full HTML document. In current Hydrogen that’s theLayout export — so wrap Layout with withWeaverse and leave the default App export unwrapped:
withWeaverse doesn’t take a components list. Components are registered in components.ts and consumed by WeaverseContent.
v4 / Before (Remix)
v4 / Before (Remix)
In Weaverse v4 the imports came from
@remix-run/react and the default export was wrapped:3. Register Routes in app/routes.ts
React Router v7 uses config-based routing. Hydrogen wraps your route tree in hydrogenRoutes(). Add (or confirm) the routes you want Weaverse to drive — Pilot keeps them in feature folders such as routes/home.tsx and routes/products/product.tsx:
4. Adapt Route Components
For each route you want editable in Weaverse:- Load Weaverse page data in the loader with
context.weaverse.loadPage() - Validate it with
validateWeaverseData() - Render
<WeaverseContent />
app/routes/home.tsx):
app/routes/products/product.tsx):
v4 / Before (Remix imports in routes)
v4 / Before (Remix imports in routes)
In Weaverse v4, route types and hooks came from Remix packages:In v5, both come from
react-router:WeaverseContent automatically renders the content for the page type and handle you loaded, using the components registered in components.ts.
Step 6: Run and Connect
- Start your dev server:
npm run dev - Open Weaverse Studio: go to your project at studio.weaverse.io.
- Update the Preview URL: point your project’s preview URL at your local dev server. Hydrogen’s default is
http://localhost:3000; Pilot’sdevscript uses--port 3456, so match whatever port your terminal prints.
Next Steps
Create Custom Components
Build your own React components and make them editable in Weaverse.
Component Schema
Define settings, presets, and child types with
createSchema().Theme Settings
Customize global styles defined in
schema.server.ts from Studio.v5 Migration Guide
Moving an existing Weaverse v4 project to React Router v7.