Rendering Weaverse Pages
This guide covers everything you need to know about rendering different page types in Weaverse, from basic concepts to advanced implementation patterns.Core Concepts
Weaverse page rendering revolves around two key elements:loadPage()function: Loads page data based on type and handleWeaverseContentcomponent: Renders the loaded page content
The loadPage() Function
TheloadPage() function is called in your route loaders to fetch page data:
The WeaverseContent Component
TheWeaverseContent component renders the loaded page data. It automatically gets the weaverseData from your loader through the <WeaverseHydrogenRoot> wrapper:
<WeaverseHydrogenRoot> component (typically in your root layout) automatically extracts weaverseData from the current route’s loader data and provides it to all child <WeaverseContent> components through React context. This eliminates the need to manually pass the data prop.
Supported Page Types
Weaverse supports the following page types:E-commerce Pages
PRODUCT- Individual product pagesCOLLECTION- Collection/category listing pages
Content Pages
PAGE- Shopify Page resources (the pages you manage in Shopify admin), loaded with the page’shandleBLOG- Blog listing pagesARTICLE- Individual blog post pages
Special Pages
INDEX- HomepageCUSTOM- Weaverse custom pages created in Weaverse Studio; resolved from the request URL, so nohandleis passed
Pilot uses React Router 7’s manual route registry in
app/routes.ts. Creating a file under app/routes/ does not create a route — the module has to be registered with route()/index() before any URL reaches it. Route module code imports LoaderFunctionArgs, MetaFunction, and useLoaderData from react-router, and loaders return plain objects rather than json().Working with Locales
Localization is request context, not a decision repeated in every page loader. Resolve the active market once from an exact configured allowlist, then use that entry to create both the Shopify Storefront and Weaverse contexts. Normal storefront loaders can then load the active localized page without parsing the URL or hardcoding a fallback:.data requests must retain the same active market.
Use an explicit locale only for an intentional cross-locale admin or background operation, not as a second storefront routing system.
Advanced Localization Guide
Implement the exact routing, context, continuity, SEO, and translation contract.
Markets and Localization
Define the canonical market table and configure localized content.
Routes Without Weaverse Integration
Some routes in your Hydrogen theme may not use Weaverse’s page system at all. These typically include functional pages that rely heavily on Shopify’s built-in components and APIs:- Search pages - Use Shopify’s search API directly
- Cart pages - Use Shopify’s cart components and forms
- Account pages - Use Shopify’s customer account API
- Policy pages - Often render Shopify’s policy content directly
Custom Page Approach
Use the page type that matches the resource being rendered:Shopify Page Resources: PAGE Type with Handle
UsePAGE only for a Shopify Page resource, normally under /pages/:pageHandle:
Weaverse Custom Pages: CUSTOM Type
For a root-level custom page created in Studio, let Weaverse resolve the page from the current request URL:Real-World Example: Pilot Template Pattern
Pilot registers application and custom-page routes under an optional first segment, but that route parameter is not the market authority:- A configured prefix selects its exact Shopify and Weaverse market context.
- An invented prefix such as
/en-xxreturns 404 before any route can serve default-market content there. - Ordinary root-level handles such as
/about-usor/hi-indiacontinue to the Weaverse custom-page path. - The catch-all loads custom pages with
loadPage({type: "CUSTOM"}); it does not reinterpret arbitrary text as a locale.
Basic Implementation
Here’s the standard pattern for implementing Weaverse page rendering in a React Router v7 route:1. Route Loader
2. Route Component
Page Type Examples
Product Page
Collection Page
Custom Page
Blog Page
Homepage
Custom Pages
Custom pages are built in Weaverse Studio and are rendered with theCUSTOM type. Weaverse resolves which custom page to serve from the request URL, so you do not pass a handle.
Root-Level Custom Pages Need No New Route
Pilot’s catch-all already covers every unmatched URL, so a custom page published at/about is served without touching app/routes.ts:
/promo/...) — and load it with type: "CUSTOM" too. Remember to register it in app/routes.ts:
Shopify Pages (PAGE + handle)
PAGE is for Shopify Page resources, not for Weaverse custom pages. Pilot serves these at /pages/:pageHandle:
Error Handling
404 Error Handling
Always check if the page data exists and handle 404 cases:Fallback Rendering
Provide fallback content when Weaverse data is unavailable:Error Boundaries
Use error boundaries for graceful error handling:Performance Best Practices
Parallel Data Loading
Always load Weaverse data in parallel with other API calls:Caching
Use proper cache headers for Weaverse pages:Preloading
Consider preloading critical page data:Troubleshooting
Common Issues
1. Page Type Mismatch
Problem: Wrong page type specified inloadPage()
CUSTOM from the route.
2. Missing Handle Parameter
Problem: Handle not provided or undefined3. Component Not Rendering
Problem: Weaverse components not registered properly Solution: Ensure components are registered in~/weaverse/components.ts (or ~/app/weaverse/components.ts in Pilot template):
* as ComponentName) and restart your dev server after registration.
4. TypeScript Errors
Problem: Type errors withWeaverseContent
Solution: Ensure proper type imports:
Next Steps
- Learn about Custom Component Development
- Explore Data Fetching Patterns
- Master Component Schemas
- Review API Reference