Skip to main content
Initializes the customer session by checking for a stored access token. If a valid token exists, fetches and returns the customer data. Call this on page load to restore logged-in state.

Returns

Promise<ShopifyCustomer | null> - Customer object if logged in, null otherwise.

Examples

Basic initialization

Handling an expired session

.init() never throws — if the stored token is invalid or expired, the token is cleared and null is returned.

Combined with subscribe

Always call .init() early in your page lifecycle. This restores the customer session and triggers any subscribers with the current state.