UserIdResolver

Learn about the function that resolves the logged-in user ID.

This type describes the function the SDK uses to resolve the ID of the logged-in customer for a request.

Provide one through the resolver options to override the default, which reads the logged-in customer from the Shopify Customer Account API.

Definition

The type has the following shape:

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

The function receives the Hydrogen request context and returns the user ID, or nothing for anonymous visitors. It may be synchronous or asynchronous.