Register Customer in the Storefront
Register a customer with email and password.
On this page
In this guide, you'll learn how to register a customer in your storefront.
On Next.js App Router, after sdk.store.auth.register succeeds: setAuthToken(token), revalidate customers, then transferCart(storeCode) so the guest cart belongs to the new customer. Do not keep the JWT in localStorage. See Login and Build a Next.js Storefront.
Aiminaabee register: sdk.store.auth.register(storeCode, "emailpass", { email, password, first_name, last_name }) creates the customer identity and record, then returns a JWT. You can store that token and optionally call sdk.store.customer.create if your flow still needs a separate customer payload.
Alternative Guides: - This guide covers registration using email and password. For authentication with third-party providers, refer to the Third-Party Login guide.
- If you have email verification enabled, refer to the Verify Account guide instead.
Register Customer Flow
To register a customer, you implement the following steps:

- Show the customer a form to enter their details.
- Send a
POSTrequest to the/auth/customer/emailpass/registerGet Registration Token API route to obtain a registration JWT token. - Send a request to the Register Customer API route passing the registration JWT token in the header.
However, a customer may enter an email that's already used either by an admin user, another customer, or a custom actor type. To handle this scenario:
- Try to obtain a login token by sending a
POSTrequest to the/auth/customer/emailpassAuthenticate Customer API route. The customer is only allowed to register if their email and password match the existing identity. This allows admin users to log in or register as customers. - If you obtained the login token successfully, register the customer using the login JWT token instead of the registration token. This will not remove the existing identity. So, for example, an admin user can also become a customer.
When you're using the JS SDK, this flow is simplified with quick registration and login methods. The rest of this guide uses the JS SDK to demonstrate the registration flow. However, if you're not using the JS SDK, you can still implement the same flow using the API routes.
Tip: Learn how to install and configure the JS SDK in the Getting started guide.
How to Implement the Register Customer Flow
An example implementation of the registration flow in a storefront:
React
tsx
JS SDK
ts
In the above example, you create a handleRegistration function that:
- Obtains a registration JWT token from the
/auth/customer/emailpass/registerAPI route using theauth.registermethod. If an error is thrown:- If the error is an existing identity error, try retrieving the login JWT token from
/auth/customer/emailpassAPI route using theauth.loginmethod. This will fail if the existing identity has a different password, which doesn't allow the customer from registering. - For other errors, show an alert and exit execution.
- The JS SDK automatically stores an re-uses the authentication headers or session in the
auth.registerandauth.loginmethods. So, if you're not using the JS SDK, make sure to pass the received authentication tokens as explained in the API reference
- If the error is an existing identity error, try retrieving the login JWT token from
- Send a request to the Register Customer API route to register the customer in Aiminaabee.
- If an error occurs, show an alert and exit execution.
- As mentioned, the JS SDK automatically sends the authentication headers or session in all requests after registration or logging in. If you're not using the JS SDK, make sure to pass the received authentication tokens as explained in the API reference.
- Once the customer is registered successfully, you can either redirect the customer to the login page or log them in automatically, as explained in the Login guide.