shoppy.customer.reset(resetToken, newPassword)
Resets the customer’s password using the token received via email. On success, automatically logs in the customer.
Parameters
| Param | Type | Required | Description |
|---|
resetToken | string | Yes | Token from reset email URL |
newPassword | string | Yes | New password |
Returns
Promise<ShopifyCustomer> - The authenticated customer.
Throws
Error - If token is invalid/expired or password doesn’t meet requirements.
Examples
Reset password page
// URL: /reset-password?token=CUSTOMER_ID/RESET_TOKEN
const urlParams = new URLSearchParams(window.location.search)
const resetToken = urlParams.get('token')
document.querySelector('#reset-form').addEventListener('submit', async (e) => {
e.preventDefault()
const password = document.querySelector('#password').value
const confirmPassword = document.querySelector('#confirm-password').value
if (password !== confirmPassword) {
showError('Passwords do not match')
return
}
try {
await shoppy.customer.reset(resetToken, password)
showSuccess('Password updated! Redirecting to your account...')
setTimeout(() => {
window.location.href = '/account'
}, 2000)
} catch (error) {
showError(error.message)
}
})
// Shopify reset URLs look like:
// https://yourstore.myshopify.com/account/reset/CUSTOMER_ID/TOKEN
function extractResetToken(url) {
const match = url.match(/\/reset\/(\d+)\/([a-z0-9-]+)/i)
if (match) {
return `${match[1]}/${match[2]}`
}
return null
}
// On your reset page
const resetToken = extractResetToken(document.referrer) ||
new URLSearchParams(location.search).get('token')
Reset tokens expire after a period set by Shopify. If the token is expired, prompt the user to request a new reset email.