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 — createAccount({ email, password }) creates a customer via CUSTOMER_CREATE
  2. Login — login(email, password) creates an access token via CUSTOMER_ACCESS_TOKEN_CREATE, syncs it to the SDK context and the cart’s buyer identity
  3. Authed state — customer.getAccessToken() returns the current token
  4. Logout — logout() deletes the token on Shopify and clears it from memory

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):