# 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](/reference/sdk/hydrogen/api/types/croct-options) to override the default, which reads the logged-in customer from the Shopify [Customer Account API](https://shopify.dev/docs/api/customer).

## Definition

The type has the following shape:

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

The function receives the [Hydrogen request context](/reference/sdk/hydrogen/api/types/resolver-context) and returns the user ID, or nothing for anonymous visitors. It may be synchronous or asynchronous.
