Skip to main content
openbridge.customer
Full customer authentication system using Shopify’s Storefront API. No backend required - Shopify is your user database.
See Types for full interface definitions.

Features

  • No Backend Needed - Shopify handles all user data and authentication
  • Session Persistence - Customer stays logged in across browser sessions
  • Reactive Updates - Subscribe to auth state changes for automatic UI updates
  • Full Account Access - Orders, addresses, profile management

Methods

.init()

Initialize customer session

.login()

Log in with email and password

.register()

Create new customer account

.logout()

Log out current customer

.get()

Get current customer profile

.update()

Update customer profile

.orders()

Get order history

.addresses()

Manage shipping addresses

.recover()

Send password reset email

.reset()

Reset password with token

.subscribe()

Listen for auth changes

Quick Example

// Initialize on page load - auto-restores session
const customer = await openbridge.customer.init()

if (customer) {
    console.log(`Welcome back, ${customer.firstName}!`)
} else {
    console.log('Not logged in')
}

// Subscribe to auth changes
openbridge.customer.subscribe((customer) => {
    if (customer) {
        showAccountMenu(customer)
    } else {
        showLoginButton()
    }
})

// Login
const customer = await openbridge.customer.login('email@example.com', 'password')

// Get order history
const { orders } = await openbridge.customer.orders()

// Logout
await openbridge.customer.logout()

How It Works

  1. Customer logs in → Shopify validates credentials and returns an access token
  2. Token stored locally → Saved in localStorage with expiration
  3. Token auto-restores → Call .init() on page load to restore session
  4. Token used for API calls → All customer operations use the stored token
Access tokens expire after a period set by Shopify (typically 2 weeks). The SDK automatically clears expired tokens.