Skip to main content

Customer & Orders

The SDK provides authentication, profile management, and order history through the Shopify Storefront GraphQL API. Tokens are managed in-memory by the CustomerService and synced via useStackfront().setCustomerAccessToken.

Quick Reference

Authentication Flow

  1. Register — register({ email, password }) creates a customer via CUSTOMER_CREATE and opens a session with the same credentials in one action. createAccount(...) remains available for create-only.
  2. Login — login(email, password) creates an access token via CUSTOMER_ACCESS_TOKEN_CREATE and syncs it to the SDK context (it also links the push device to the customer). Cart buyer identity is not set automatically — set it manually via updateBuyerIdentity after login (see Cart Integration below)
  3. Authed state — hasSession / isAuthenticated (and customer.getAccessToken()) tell the UI a session exists; a revoked token clears itself and flips them back to false
  4. Logout — logout() deletes the token on Shopify and clears it from memory and storage

Cart Integration

When a customer logs in, the SDK automatically:
  • Sets the customer access token in the CustomerService
  • Calls setCustomerAccessToken at the provider level
  • Links the customer ID to the push notification device
  • Tracks login and logout events
To associate the cart with the logged-in customer, call updateBuyerIdentity after login (available via useCart):