Skip to main content
The useCustomer hook provides full authentication lifecycle management.

Hook API

Login

Register

register creates the account and opens a session in one action. Shopify’s customerCreate never returns a token, so the SDK performs the follow-up login with the same credentials — the caller does not have to.
createAccount remains available when you deliberately want account creation without a session. It now throws CustomerCreateError on customerUserErrors instead of silently returning a failed payload.
A double tap cannot create two accounts or two sessions: the hook serializes auth actions, so the second submit is a no-op.

Logout

Password Recovery

Update Profile

Account deletion is not available. The Shopify Storefront API has no customerDelete mutation (verified against 2026-07), so the SDK cannot offer one; merchants handle deletions from Shopify Admin. Don’t build a “delete account” screen against this SDK until Shopify ships a Storefront mutation for it.

Session security

  • The session token (and its Shopify expiry) persists across cold starts and is dropped if already expired.
  • Dead-session self-heal: Shopify answers a revoked/invalid token with { customer: null } (no GraphQL error — verified against 2026-07). The SDK treats that as authoritative: it clears the in-memory and persisted token, drops auth-scoped query caches and API attribution, and hasSession becomes false, so the app falls back to the signed-out state instead of retrying a dead token forever. Scores/order/address reads behave the same — a dead session never masquerades as “no orders”.
  • Automatic token renewal: when a token is within 30 days of its Shopify expiry, the next authenticated read renews it transparently and persists the new expiry. Renewal is single-flight: several reads that refresh at the same time rotate the token once. A transport failure keeps the working token; a renewal Shopify rejects clears the session.
  • Boot renewal: a restored token already inside the renewal window is renewed during provider init (best-effort). An offline boot keeps the cached token.
  • Keychain storage (opt-in): hold the token in the device keychain instead of AsyncStorage by passing a keychain storage from the /keychain subpath:
Items are stored device-only (never synced to an iCloud backup), so a restored backup cannot resurrect someone else’s session. Only the customer session uses this store; the rest of the SDK keeps its own AsyncStorage caches.

Not included: multi-account sessions and lock/unlock

The SDK intentionally keeps ONE active customer session per install. Storing several long-lived Shopify tokens on a device multiplies the exposure while a “lock” that only flips a boolean (without biometric verification) is cosmetic. If your app needs account switching, sign out and sign in with the other account; if it needs app-lock, gate the UI behind the platform’s biometric API.

Service API

For imperative access:
Error classes exported with the SDK: