Skip to main content
Migrate to Polaris

Version 2025-07 is the last API version to support React-based UI components. Later versions use web components, native UI elements with built-in accessibility, better performance, and consistent styling with Shopify's design system. Check out the migration guide to upgrade your extension.

Storefront API

The Storefront API lets you query the GraphQL Storefront API to read product, collection, and other storefront data from within your extension. Use this API to display product recommendations, look up collection details, or fetch any publicly available storefront information.

This API requires the api_access capability. Enable it under [extensions.capabilities] in your extension's configuration.

For customer and order data, use the Customer Account API.

  • Display product recommendations: Query products by collection or tag and render personalized suggestions on customer account pages.
  • Show order-related products: Fetch product details for items in a customer's order to display warranty information, care instructions, or upsell opportunities.
  • Build collection browsers: Query collections to let customers browse and save products directly from a full-page extension.
  • Enrich extension content with storefront data: Pull product images, descriptions, and pricing to create rich, data-driven extension experiences.
Support
Targets (25)

The Storefront API object provides the query interface for the GraphQL Storefront API. Access the following properties on the API object to fetch product, collection, and other storefront data.

Anchor to query
query
<Data = unknown, Variables = { [key: string]: unknown; }>(query: string, options?: { variables?: Variables; version?: ; }) => Promise<{ data?: Data; errors?: []; }>
required

Queries the Storefront GraphQL API using a prefetched token. Requires the api_access capability in your extension configuration.


  • Prefer shopify.query() over raw fetch(): The query helper automatically handles GraphQL Storefront API authentication, versioning, and request formatting. Use fetch() only when you need lower-level control over the request.
  • Request only the fields you need: Write targeted GraphQL queries that select specific fields rather than requesting entire objects. This reduces response size and improves extension performance.
  • Cache responses when appropriate: If you're querying data that doesn't change frequently (such as collection metadata), store the result in component state to avoid redundant network requests on re-renders.
  • Handle errors and loading states: Always check for errors in the GraphQL response and display appropriate loading indicators while queries are in flight.

  • The api_access capability must be enabled in your extension's configuration before you can use this API. Queries will fail without it.
  • The global fetch() approach requires you to manually specify the API version in the URL. If you use an unsupported version, the request will fail.
  • Query complexity and rate limits from the GraphQL Storefront API still apply. Extensions that issue many concurrent queries may be throttled.

Was this page helpful?