Initialize the Shopify Storefront API client in Hydrogen with a public access token and query a product by handle including metafields

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. Install or verify the @shopify/hydrogen package and confirm the createStorefrontClient function is available in your project
  2. Call createStorefrontClient in your server entry with the storefront token, shop domain, and API version; export the resulting storefront object for use in loaders
  3. In a route loader, call storefront.query with an inline GraphQL document that queries the product by handle and includes a metafields connection with the desired namespace and key
  4. Because the Storefront API requires metafield identifiers to be declared in the query via the identifiers argument on the metafields field, pass them as query variables rather than hardcoding them
  5. Return the product data from the loader and access it via useLoaderData in the route component
  6. Handle the case where the product is null or the metafield value is null gracefully in the UI

Known gotchas

Related routes

Initialize a Hydrogen storefront with createStorefrontClient and make an authenticated Storefront API request inside a Remix loader
shopify.dev · 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
Create a Shopify metaobject definition with field validations and create entries via Admin GraphQL, then expose entries via the Storefront API
shopify.dev · 6 steps · unrated

Give your agent this knowledge — and 16,300+ more routes

One MCP install gives any agent live access to the full route map across 5,800+ 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