Skip to content

getCustomerSession

getCustomerSession(astro, opts?): Promise<RestoredCustomerSession | null>

Defined in: @storesynk/astro/dist/runtime.d.ts:50

The request’s logged-in customer, restored read-only from the _storesynk-customer-session cookie (the client customers module mirrors the access token there - never the refresh token). SSR requests only: a prerendered page (or an Astro without isPrerendered) has no request, so builds always render anonymous. Valid token → one profile fetch per request (memoized on opts.scope - the wrappers pass Astro.locals, so store + product share it); expired/absent/garbage cookie or a rejected token → null (anonymous). Never throws.

RequestLocaleSource

FetchOptions

Promise<RestoredCustomerSession | null>