Hydrogen React
Hydrogen React is a performant, framework-agnostic library of React components, reusable functions, and utilities for interacting with Shopify’s Storefront API. It’s bundled with Hydrogen, but can be used by any React-based web app.
Anchor to setupSetup
- Install Hydrogen React in your project with your preferred package manager.
- Import components, hooks, or utilities that you want to use in your app. For more detailed instructions, see the Getting Started guide.
Install the Hydrogen React package
Anchor to authenticationAuthentication
To use Hydrogen React, you need to authenticate with and make requests to the Storefront API. Hydrogen React includes an API client to securely handle API queries and mutations.
You can create and manage Storefront API access tokens by installing the Headless sales channel on your store.
Apps have access to two kinds of tokens: a public API token, which can be used in client-side code, and a private API token, which should only be used in server-side contexts and never exposed publicly.
Authenticate a Hydrogen app
Anchor to versioningVersioning
Hydrogen React is tied to specific versions of the Storefront API, which is versioned quarterly. For example, if you're using Storefront API version 2023-10
, then Hydrogen versions 2023.10.x
are fully compatible.
If a Storefront API version includes breaking changes, then the corresponding Hydrogen React version will include the same breaking changes.
Anchor to componentsComponents
Components include all the business logic and data parsing required to produce predictable markup for objects available through the Storefront API. Components provide defaults but can be customized. Hydrogen React components include no visual styles, other than the ones provided natively by browsers.
Component example
Component
Anchor to hooksHooks
Hooks are functions that provide reusable business and/or state logic. They give you additional flexibility to control the behavior and display of Hydrogen React components.
Hook example
Hook
Anchor to utilitiesUtilities
Utilities are reusable functions for common manipulations performed on data returned from the Storefront API.
Utility example
Utility
Anchor to with_hydrogenHow Hydrogen React works with Hydrogen
Hydrogen React is bundled as part of Hydrogen, Shopify’s opinionated headless commerce stack built on Remix. Hydrogen React is also published separately as a standalone package so that it can be used by other React-based frameworks.
Hydrogen adds features like standard routes, caching strategies, redirects, and SEO. When using Hydrogen, you can also install the Hydrogen sales channel, which includes built-in support for Oxygen, Shopify’s global edge hosting platform. Consider which approach works best for your use case and existing technology stack.