Skip to main content

createHydrogenContext

The createHydrogenContext function creates the context object required to use Hydrogen utilities throughout a Hydrogen project.

Anchor to createhydrogencontext(options)createHydrogenContext(options)

TEnv
required
Anchor to request
request
required
Anchor to session
session
TSession
required

Any cookie implementation. By default Hydrogen ships with cookie session storage, but you can use another session storage implementation.

Anchor to buyerIdentity
buyerIdentity

Buyer identity. Default buyer identity is passed to cartCreate.

Anchor to cache
cache
Cache

An instance that implements the Cache API

{ getId?: () => string; setId?: (cartId: string) => ; queryFragment?: string; mutateFragment?: string; customMethods?: Record<string, Function>; }

Cart handler overwrite options. See documentation for createCartHandler for more information.

Anchor to customerAccount
customerAccount
{ apiVersion?: string; authUrl?: string; customAuthStatusHandler?: () => {} | Response; unstableB2b?: boolean; useCustomAuthDomain?: boolean; }

Customer Account client overwrite options. See documentation for createCustomerAccountClient for more information.

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 storefront
storefront
{ headers?: StorefrontHeaders; apiVersion?: string; }

Storefront client overwrite options. See documentation for createStorefrontClient for more information.

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.



Was this page helpful?