Customer & Payment Events
These events handle customer data changes and payment method updates.
customer:update
Dispatched by store when the customer data changes.
eventPayload
Storefront only. When triggered by a login or logout action, this event includes state.eventPayload with context about the action:
| Property | Type | Description |
|---|---|---|
action | string | The action that triggered the update: "customer:login" or "customer:logout". |
data | object | The customer data at the time of the action (matches state.customer). For logout, this is the customer data before the logout. |
path | string | Always "customer". |
In checkout, this event may not include eventPayload (it will be null). Always check before accessing.
import type { NubeSDK } from "@tiendanube/nube-sdk-types";
export function App(nube: NubeSDK) {
nube.on("customer:update", ({ customer, eventPayload }) => {
if (eventPayload?.action === "customer:login") {
console.log("Customer logged in:", customer?.contact?.email);
} else if (eventPayload?.action === "customer:logout") {
console.log("Customer logged out");
} else {
console.log("Customer data updated", customer?.contact?.email);
}
});
}
account:register
Storefront only. Dispatched by app to pre-fill (autocomplete) the storefront signup form. Send it with a modifier that returns the customer data to populate; the store merges the provided fields into state.customer.
| Field | Type | Description |
|---|---|---|
name | string | Customer's full name. |
email | string | Customer's email address. |
phone | string | Customer's phone number. |
cpf_cnpj | string | Customer's identification document (CPF / CNPJ). |
All fields are optional — send only the ones you want to pre-fill.
import type { NubeSDK } from "@tiendanube/nube-sdk-types";
export function App(nube: NubeSDK) {
nube.send("account:register", () => ({
customer: {
name: "John Doe",
email: "john@example.com",
phone: "+5511999999999",
cpf_cnpj: "12345678900",
},
}));
}
payment:update
Checkout only. Dispatched by checkout when the payment method changes.
import type { NubeSDK } from "@tiendanube/nube-sdk-types";
export function App(nube: NubeSDK) {
nube.on("payment:update", ({ payment }) => {
console.log("Payment method has changed to:", payment?.selected);
});
}
Help us improve NubeSDK
Found an issue or have a suggestion? Let us know on GitHub.