Skip to main content
This guide details how to integrate the Weaverse SDK into your existing Shopify Hydrogen project. By adding Weaverse, you empower your storefront with visual page building, theme customization through the Weaverse Studio, and access to a growing library of components, significantly speeding up development and content management.
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)
Not sure which you have? Check package.json for react-router vs @remix-run/react.
All code in this guide targets Weaverse v5 + React Router v7 and mirrors the current Pilot theme. Legacy Remix snippets appear only in examples explicitly labelled v4 / Before.

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 Remix (Legacy — v4)

How to Check Your Hydrogen Version

Check your package.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:
Replace "your-project-id" with the Project ID found in your Weaverse project settings.

Step 3: Set Up Core Weaverse Files

Create a weaverse 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.
Pilot splits its theme settings into one file per group under app/weaverse/settings/ and composes them in the settings array. It’s a good pattern once the schema grows.

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 makes context.weaverse available in every loader and action.

1. Update Your Context File

In current Hydrogen, the context lives in app/.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:
Do not write return { ...hydrogenContext, weaverse }. Spreading flattens the RouterContextProvider instance into a plain object and Hydrogen’s context APIs (context.get, middleware) will fail at runtime.
This modification:
  1. Imports WeaverseClient from the Weaverse Hydrogen SDK
  2. Imports your theme schema and components from the files created in the previous step
  3. Initializes a WeaverseClient with the Hydrogen context, request, and cache
  4. Attaches the client to the existing context instance, exposing it as context.weaverse

2. Ensure Your Server Entry Uses the Context

Your server.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 the Layout export — so wrap Layout with withWeaverse and leave the default App export unwrapped:
Wrap Layout, not the default export. Wrapping App with withWeaverse leaves the Weaverse providers below the document boundary, so theme settings and Studio design mode won’t initialize correctly.
Note: withWeaverse doesn’t take a components list. Components are registered in components.ts and consumed by WeaverseContent.
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:
The route("*", "routes/catch-all.tsx") entry lets Weaverse-authored custom pages resolve at arbitrary handles. Without it, custom pages created in Studio will 404.

4. Adapt Route Components

For each route you want editable in Weaverse:
  1. Load Weaverse page data in the loader with context.weaverse.loadPage()
  2. Validate it with validateWeaverseData()
  3. Render <WeaverseContent />
Homepage (app/routes/home.tsx):
Product page (app/routes/products/product.tsx):
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

  1. Start your dev server: npm run dev
  2. Open Weaverse Studio: go to your project at studio.weaverse.io.
  3. Update the Preview URL: point your project’s preview URL at your local dev server. Hydrogen’s default is http://localhost:3000; Pilot’s dev script uses --port 3456, so match whatever port your terminal prints.
You should now see your Hydrogen storefront loaded inside the Weaverse editor, ready for visual editing.

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.
By following these steps, you can successfully integrate Weaverse into your existing Hydrogen project, unlocking powerful visual editing and customization capabilities.