Customer Addresses
Manage shipping and billing addresses.
Updated
On this page
Overview
Customer addresses are stored as part of the customer profile. The primary address is used as the default shipping address during checkout.
Reading the Address
import dash from "@/lib/dash"
const { customer } = await dash.auth.getProfile()
if (customer.has_address) {
const addr = customer.address
console.log(addr.address_line1) // "123 Main St"
console.log(addr.city) // "Austin"
console.log(addr.state) // "TX"
console.log(addr.zip_code) // "78701"
console.log(addr.country) // "US"
}
Updating the Address
const { customer } = await dash.auth.updateProfile({
address_line1: "456 Oak Ave",
address_line2: "Suite 100",
city: "Dallas",
state: "TX",
zip_code: "75001",
country: "US",
})
Address Validation
Validate and standardize addresses using the shipping module:
const result = await dash.shipping.validateAddress({
address_line1: "456 Oak Ave",
city: "Dallas",
state: "TX",
postal_code: "75001",
country_code: "US",
})
// result.status = "verified" | "unverified"
// result.matched_address = standardized version
Using in Checkout
Pre-fill the checkout shipping form with the customer's saved address:
const { customer } = await dash.auth.getProfile()
// Pre-fill checkout shipping
await dash.checkout.complete({
cartId: dash.cart.cartId,
shipping: {
first_name: customer.first_name,
last_name: customer.last_name,
address_line1: customer.address.address_line1,
city: customer.address.city,
state: customer.address.state,
zip_code: customer.address.zip_code,
country: customer.address.country,
phone: customer.phone,
},
// ...
})
Next Steps
- Customer Orders — Order history
- Shipping Locations — Available shipping destinations
- Create Order — Using addresses in checkout