@weaverse/hydrogen/next API Reference
The Next.js adapter ships in@weaverse/hydrogen (install @weaverse/hydrogen) and has two entry points:
Server code lives under
@weaverse/hydrogen/next/server so a Client Component can import the root entry without pulling server-only fetch code into the browser bundle.
The root entry is safe in Server Components: its components, hooks and runtime are Client Components (render them, don’t call them on the server), and its schema helpers run as ordinary server functions.
@weaverse/next is deprecated. Its root and /server entries exported more than @weaverse/hydrogen/next does: the page, root and commerce data hooks, the lower-level Studio runtime, loader and revalidation helpers, the ThemeText* aliases, and the server config and page URL helpers. Only the exports listed on this page are available.@weaverse/hydrogen/next
Components and providers
Hooks
Studio
Translation
See Markets & translations.
SEO
Both are also exported from
@weaverse/hydrogen/next/server. See Rendering pages.
Schema and errors
Types
@weaverse/hydrogen/next/server
Types:
WeaverseNextServerClient, WeaverseNextServerClientConfig, WeaverseNextServerLoadPageInput, WeaverseNextThemeSettingsOptions, WeaverseNextThemeSettingsResponse, WeaverseNextConfigs, WeaverseNextBaseConfigs, WeaverseNextCacheConfig, WeaverseNextFetchOptions, WeaverseNextCustomPageEntry, WeaverseNextFetchCustomPagesOptions, WeaverseNextProjectId, WeaverseNextRevalidateHandler, WeaverseNextRevalidateHandlerConfig, WeaverseStudioCspDirectives, WeaverseLoadFailureKind (6.5.0+), the SEO types (WeaverseNextSeoInput, WeaverseNextSeoMetadata, WeaverseNextSeoPageContainer, NextOpenGraph, NextTwitter), plus the shared types above.
Server client config
Server client members
Config resolution
- Project id:
?weaverseProjectId=→projectIdfunction →projectIdstring →WEAVERSE_PROJECT_ID. - Studio host: trusted
?weaverseHost=(https://*.weaverse.io,https://*.weaverse.dev) →WEAVERSE_HOST→https://studio.weaverse.io. - API base: trusted request host →
WEAVERSE_PUBLIC_API_BASE→ non-productionWEAVERSE_HOST→https://api.weaverse.io. - Public env:
PUBLIC_STORE_DOMAIN,PUBLIC_STOREFRONT_API_TOKEN.
getWeaverseStudioCspDirectives
@weaverse/hydrogen 6.3.0 and later. Returns the CSP sources Weaverse Studio needs for this request, shaped like Hydrogen’s ContentSecurityPolicyDirectives so you can append them to your directives before calling createContentSecurityPolicy (@shopify/hydrogen 2026.10.3+):
{}for normal visitors, and for a relative or malformed URL.- On Studio requests (design mode, section preview or revision preview) with a trusted
weaverseHost(https://onweaverse.ioorweaverse.dev): the Studio origin inframeAncestors,scriptSrc,connectSrc,styleSrc,fontSrcandimgSrc. Design mode adds'unsafe-eval'toscriptSrc. {}for an untrustedweaverseHost, so a crafted URL can’t widen the policy.
@weaverse/hydrogen/react-router; see getWeaverseStudioCspDirectives. For a full setup, see Studio integration.