createHydrogenContext
The createHydrogenContext function creates the context object required to use Hydrogen utilities throughout a Hydrogen project.
Anchor to createhydrogencontext(options)createHydrogenContext(options)
- Anchor to envenvenvTEnvTEnvrequiredrequired
- Anchor to requestrequestrequestCrossRuntimeRequestCrossRuntimeRequestrequiredrequired
- Anchor to sessionsessionsessionTSessionTSessionrequiredrequired
Any cookie implementation. By default Hydrogen ships with cookie session storage, but you can use another session storage implementation.
- Anchor to buyerIdentitybuyerIdentitybuyerIdentityCartBuyerIdentityInputCartBuyerIdentityInput
Buyer identity. Default buyer identity is passed to cartCreate.
- Anchor to cachecachecacheCacheCache
An instance that implements the Cache API
- Anchor to cartcartcart{ getId?: () => string; setId?: (cartId: string) => Headers; queryFragment?: string; mutateFragment?: string; customMethods?: Record<string, Function>; }{ getId?: () => string; setId?: (cartId: string) => Headers; queryFragment?: string; mutateFragment?: string; customMethods?: Record<string, Function>; }
Cart handler overwrite options. See documentation for createCartHandler for more information.
- Anchor to customerAccountcustomerAccountcustomerAccount{ apiVersion?: string; authUrl?: string; customAuthStatusHandler?: () => {} | Response; unstableB2b?: boolean; useCustomAuthDomain?: boolean; }{ apiVersion?: string; authUrl?: string; customAuthStatusHandler?: () => {} | Response; unstableB2b?: boolean; useCustomAuthDomain?: boolean; }
Customer Account client overwrite options. See documentation for createCustomerAccountClient for more information.
- Anchor to i18ni18ni18nTI18nTI18n
An object containing a country code and language code
- Anchor to logErrorslogErrorslogErrorsboolean | ((error?: Error) => boolean)boolean | ((error?: Error) => boolean)
Whether it should print GraphQL errors automatically. Defaults to true
- Anchor to storefrontstorefrontstorefront{ headers?: StorefrontHeaders; apiVersion?: string; }{ headers?: StorefrontHeaders; apiVersion?: string; }
Storefront client overwrite options. See documentation for createStorefrontClient for more information.
- Anchor to waitUntilwaitUntilwaitUntilWaitUntilWaitUntil
The
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.
CartBuyerIdentityInput
Headers
CrossRuntimeRequest
- headers
{ get?: (key: string) => string | null | undefined; [key: string]: any; } - method
string - url
string