Initialize a Hydrogen storefront with createStorefrontClient and make an authenticated Storefront API request inside a Remix loader

domain: shopify.dev · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

In-depth guide

Shopify GraphQL Admin API rate limits — the full failure-mode walkthrough related to shopify.dev, checked against official docs, with linked verified routes.

Steps

  1. In your Hydrogen app server entry (typically server.ts) call createStorefrontClient with storeDomain, publicStorefrontToken (for client-side use), and privateStorefrontToken (for server-side use); these are set as Oxygen environment variables
  2. The client returns a storefront object with storefront.query and storefront.mutate methods; pass the storefront through the Remix app context so loaders can access it
  3. In a Remix loader use const { storefront } = context to get the client, then call const { product } = await storefront.query(PRODUCT_QUERY, { variables: { handle } }) where PRODUCT_QUERY is a tagged gql template string
  4. Define PRODUCT_QUERY with the fields you need; the privateStorefrontToken is used automatically on the server so you don't need to pass an Authorization header manually — the client handles it
  5. Return the data from the loader as json(data) and consume it in the route component with useLoaderData()
  6. For caching annotate the query call with cache: storefront.CacheLong() or storefront.CacheShort() to control how Oxygen's edge cache stores the response

Known gotchas

Related routes

Initialize the Shopify Storefront API client in Hydrogen with a public access token and query a product by handle including metafields
shopify.dev · 6 steps · unrated
Build a BigCommerce custom app using storefront API tokens to implement a headless B2B quote request workflow
BigCommerce B2B headless · 6 steps · unrated
Implement Shopify Customer Account API OAuth flow in a Hydrogen app to authenticate buyers and access account data
shopify.dev · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans