Skip to main content
shoppy.customer.logout()
Logs out the current customer by invalidating the access token on Shopify’s servers and clearing the local token storage.

Returns

Promise<void>

Examples

Basic logout

await shoppy.customer.logout()
console.log('Logged out successfully')
window.location.href = '/'

Logout button handler

document.querySelector('#logout-btn').addEventListener('click', async () => {
    await shoppy.customer.logout()

    // UI will update automatically if using subscribe()
    window.location.reload()
})

With confirmation

async function handleLogout() {
    if (confirm('Are you sure you want to log out?')) {
        await shoppy.customer.logout()
        showToast('You have been logged out')
        redirectToHome()
    }
}
Logout triggers all subscribers with null, so your UI can automatically update to show the logged-out state.