Customer & Orders
The SDK provides authentication, profile management, and order history through the Shopify Storefront GraphQL API. Tokens are managed in-memory by theCustomerService and synced via useStackfront().setCustomerAccessToken.
Quick Reference
| Hook | Purpose |
|---|---|
useCustomer() | Login, logout, register, profile, password recovery |
useOrders() | Order history for logged-in customers |
Authentication Flow
- Register —
createAccount({ email, password })creates a customer viaCUSTOMER_CREATE - Login —
login(email, password)creates an access token viaCUSTOMER_ACCESS_TOKEN_CREATE, syncs it to the SDK context and the cart’s buyer identity - Authed state —
customer.getAccessToken()returns the current token - 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
setCustomerAccessTokenat the provider level - Links the customer ID to the push notification device
- Tracks
loginandlogoutevents
updateBuyerIdentity after login (available via useCart):