LocaleResolver

Learn about the function that resolves the visitor's preferred locale.

This type describes the function the SDK uses to resolve the preferred content locale for a request.

Provide one through the resolver options to override the default, which derives the locale from the storefront’s i18n configuration.

Definition

The type has the following shape:

type LocaleResolver = (context: ResolverContext) => Promise<string | null> | string | null;

The function receives the Hydrogen request context and returns a BCP‑47 locale such as en-US, or nothing to use the default locale of your workspace. It may be synchronous or asynchronous.