Skip to main content
shoppy.customer.register(input)
Creates a new customer account in Shopify. On success, automatically logs in the customer and returns their data.

Parameters

ParamTypeRequiredDescription
inputCustomerRegisterInputYesRegistration details

CustomerRegisterInput

FieldTypeRequiredDescription
emailstringYesCustomer’s email
passwordstringYesAccount password
firstNamestringNoFirst name
lastNamestringNoLast name
phonestringNoPhone number
acceptsMarketingbooleanNoMarketing opt-in

Returns

Promise<ShopifyCustomer> - The newly created and authenticated customer.

Throws

  • Error - If registration fails (e.g., email already exists).

Examples

Basic registration

try {
    const customer = await shoppy.customer.register({
        email: '[email protected]',
        password: 'securePassword123'
    })

    console.log(`Account created for ${customer.email}`)
} catch (error) {
    console.error(error.message) // "Email has already been taken"
}

Full registration form

document.querySelector('#register-form').addEventListener('submit', async (e) => {
    e.preventDefault()

    const formData = new FormData(e.target)

    try {
        const customer = await shoppy.customer.register({
            email: formData.get('email'),
            password: formData.get('password'),
            firstName: formData.get('firstName'),
            lastName: formData.get('lastName'),
            phone: formData.get('phone'),
            acceptsMarketing: formData.get('marketing') === 'on'
        })

        // Customer is now logged in
        window.location.href = '/welcome'
    } catch (error) {
        showError(error.message)
    }
})
After successful registration, the customer is automatically logged in. No need to call .login() separately.