Skip to main content

createStorefrontClient

This function extends createStorefrontClient from Hydrogen React. The additional arguments enable internationalization (i18n), caching, and other features particular to React Router and Oxygen.

The returned storefront client includes methods for proxying requests (forward, isStorefrontApiUrl) and collecting tracking information (setCollectedSubrequestHeaders).

Learn more about data fetching in Hydrogen.

Anchor to cache
cache
Cache

An instance that implements the Cache API

TI18n

An object containing a country code and language code

Anchor to logErrors
logErrors
boolean | ((error?: Error) => boolean)

Whether it should print GraphQL errors automatically. Defaults to true

Anchor to storefrontHeaders
storefrontHeaders
StorefrontHeaders

Storefront API headers. If on Oxygen, use getStorefrontHeaders()

Anchor to storefrontId
storefrontId
string

The globally unique identifier for the Shop

Anchor to waitUntil
waitUntil
WaitUntil

The waitUntil function is used to keep the current request/response lifecycle alive even after a response has been sent. It should be provided by your platform.

Anchor to StorefrontClientProps

StorefrontClientProps

Anchor to contentType
contentType
'json' | 'graphql'

Customizes which "content-type" header is added when using getPrivateTokenHeaders() and getPublicTokenHeaders(). When fetching with a JSON.stringify()-ed body, use "json". When fetching with a body that is a plain string, use "graphql". Defaults to "json"

Can also be customized on a call-by-call basis by passing in 'contentType' to both getPrivateTokenHeaders({...}) and getPublicTokenHeaders({...}), for example: getPublicTokenHeaders({contentType: 'graphql'})

Anchor to privateStorefrontToken
privateStorefrontToken
string

The Storefront API delegate access token. Refer to the authentication and delegate access token documentation for more details.

Anchor to publicStorefrontToken
publicStorefrontToken
string

The Storefront API access token. Refer to the authentication documentation for more details.

Anchor to storeDomain
storeDomain
string

The host name of the domain (eg: {shop}.myshopify.com).

Anchor to storefrontApiVersion
storefrontApiVersion
string

The Storefront API version. This should almost always be the same as the version Hydrogen React was built for. Learn more about Shopify API versioning for more details.

Anchor to storefront
storefront
<TI18n>


Was this page helpful?