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

HookPurpose
useCustomer()Login, logout, register, profile, password recovery
useOrders()Order history for logged-in customers

Authentication Flow

  1. RegistercreateAccount({ email, password }) creates a customer via CUSTOMER_CREATE
  2. Loginlogin(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 statecustomer.getAccessToken() returns the current token
  4. Logoutlogout() 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):
const { cart } = useCart();
const { customer } = useStackfront();
await cart.updateBuyerIdentity({
  customerAccessToken: customer.getAccessToken(),
});