Skip to main content
shoppy.customer.get()
Fetches the current customer’s profile data from Shopify. Requires the customer to be logged in.

Returns

Promise<ShopifyCustomer> - The customer object with profile data.

Throws

  • Error - If not logged in or token is invalid.

Examples

Get customer profile

try {
    const customer = await shoppy.customer.get()

    console.log(customer.email)
    console.log(customer.firstName, customer.lastName)
    console.log(`Total orders: ${customer.numberOfOrders}`)
} catch (error) {
    console.error('Not logged in')
}

Display account info

async function loadAccountPage() {
    const customer = await shoppy.customer.get()

    document.querySelector('#name').textContent = customer.displayName
    document.querySelector('#email').textContent = customer.email
    document.querySelector('#phone').textContent = customer.phone || 'Not set'

    if (customer.defaultAddress) {
        document.querySelector('#address').textContent =
            customer.defaultAddress.formatted.join(', ')
    }
}

Sync vs Async access

// Async - fetches fresh data from Shopify
const customer = await shoppy.customer.get()

// Sync - returns cached data (may be stale)
const cachedCustomer = shoppy.customer.getCached()

// Check login state without API call
const isLoggedIn = shoppy.customer.isLoggedIn()
MethodDescription
.getCached()Get cached customer data synchronously
.isLoggedIn()Check if customer is logged in (sync)
.getToken()Get the raw access token