---
title: Hydrogen React
description: Hydrogen React is a performant, framework-agnostic library of React components, reusable functions, and utilities for interacting with Shopify’s [Storefront API](/docs/api/storefront). It’s bundled with [Hydrogen](/docs/api/hydrogen), but can be used by any React-based web app.
api_version: 2025-04
api_name: hydrogen-react
source_url:
html: https://shopify.dev/docs/api/hydrogen-react?itcat=partnersblog&itterm=editions
md: https://shopify.dev/docs/api/hydrogen-react.md?itcat=partnersblog&itterm=editions
---
# Hydrogen React
Hydrogen React is a performant, framework-agnostic library of React components, reusable functions, and utilities for interacting with Shopify’s [Storefront API](https://shopify.dev/docs/api/storefront). It’s bundled with [Hydrogen](https://shopify.dev/docs/api/hydrogen), but can be used by any React-based web app.
***
## Setup
1. Install Hydrogen React in your project with your preferred package manager.
2. Import components, hooks, or utilities that you want to use in your app. For more detailed instructions, see the Getting Started guide.
[](https://shopify.dev/docs/custom-storefronts/hydrogen-react)
[TutorialGetting Started with Hydrogen React](https://shopify.dev/docs/custom-storefronts/hydrogen-react)
### Examples
* #### Install the Hydrogen React package
##### npm
```undefined
npm i --save @shopify/hydrogen-react
```
##### yarn
```undefined
yarn add @shopify/hydrogen-react
```
## Authentication
To use Hydrogen React, you need to authenticate with and make requests to the [Storefront API](https://shopify.dev/docs/api/storefront). Hydrogen React includes an [API client](https://shopify.dev/docs/api/hydrogen-react/2025-01/utilities/createstorefrontclient) to securely handle API queries and mutations.
You can create and manage Storefront API access tokens by installing the [Headless sales channel](https://apps.shopify.com/headless) on your store.
Apps have access to [two kinds of tokens](https://shopify.dev/docs/api/usage/authentication#access-tokens-for-the-storefront-api): 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.
[](https://apps.shopify.com/headless)
[InstallHeadless sales channel](https://apps.shopify.com/headless)
### Examples
* #### Authenticate a Hydrogen app
##### client.js
```javascript
import {createStorefrontClient} from '@shopify/hydrogen-react';
export const client = createStorefrontClient({
// load environment variables according to your framework and runtime
storeDomain: process.env.PUBLIC_STORE_DOMAIN,
publicStorefrontToken: process.env.PUBLIC_STOREFRONT_API_TOKEN,
});
```
##### .env
```undefined
# Replace with your own store domain and Storefront API token
PUBLIC_STOREFRONT_API_TOKEN="public_token"
PRIVATE_STOREFRONT_API_TOKEN="private_token"
PUBLIC_STORE_DOMAIN="store_id.myshopify.com"
```
##### server-side-query.js
```javascript
import {client} from './client.js';
export async function getServerSideProps() {
const response = await fetch(client.getStorefrontApiUrl(), {
body: JSON.stringify({
query: GRAPHQL_QUERY,
}),
// Generate the headers using the private token.
headers: client.getPrivateTokenHeaders(),
method: 'POST',
});
if (!response.ok) {
throw new Error(response.statusText);
}
const json = await response.json();
return {props: json};
}
const GRAPHQL_QUERY = `
query {
shop {
name
}
}
`;
```
## Versioning
Hydrogen React is tied to specific versions of the [Storefront API](https://shopify.dev/docs/api/storefront), which is versioned quarterly. For example, if you're using Storefront API version `2023-10`, then Hydrogen versions `2023.10.x` are fully compatible.
Caution
If a Storefront API version includes breaking changes, then the corresponding Hydrogen React version will include the same breaking changes.
[](https://shopify.dev/docs/api/usage/versioning)
[Learn moreShopify API versioning](https://shopify.dev/docs/api/usage/versioning)
[](https://shopify.dev/docs/api/release-notes)
[Learn moreAPI release notes](https://shopify.dev/docs/api/release-notes)
## Components
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.
### Examples
* #### Component example
##### Component
```javascript
import {ShopPayButton} from '@shopify/hydrogen-react';
export function MyProduct({variantId}) {
return