CroctOptions

Learn about the resolver options for the Croct middleware and context.

This type describes the options accepted by the route middleware and the context helper.

Both resolvers are optional. When omitted, the SDK reads the logged-in customer from the Shopify Customer Account API and derives the locale from the storefront’s i18n configuration.

Definition

The type has the following shape:

type CroctOptions = {  userIdResolver?: UserIdResolver;  localeResolver?: LocaleResolver;};

Properties

The following list describes the properties:

userIdResolver(optional)
(context: ResolverContext)=>Promise<string|null>

The function that resolves the ID of the logged-in customer for the current request.

It receives the Hydrogen request context and returns the user ID, or nothing for anonymous visitors.

By default, the SDK reads the logged-in customer’s ID from the Shopify Customer Account API.

localeResolver(optional)
(context: ResolverContext)=>Promise<string|null>

The function that resolves the preferred content locale for the current request.

It receives the Hydrogen request context and returns a BCP‑47 locale, or nothing to use the workspace default.

By default, the SDK derives the locale from the storefront’s i18n configuration, such as en-US.