Address book
Every mutation invalidates the address cache and the cached customer
profile, so all mounted screens agree immediately.
The list and the default address come from one Storefront request. While
signed out the hook never fetches and returns empty data.
Create form
validateAddress(input) is pure and returns
{ isValid, errors: Record<field, message> } — the same shape the reference
package used, so form code ports over directly. Required fields: first name,
last name, address line 1, city, country, zip. Province is optional (countries
without subdivisions) and only format-checked when supplied.
validateAddressUpdate(input) checks partial update payloads: blank required
fields are rejected when present, formats are validated, untouched fields are
ignored. The service calls the right validator automatically; an invalid input
never reaches the network.
Single address and default
useAddress matches by base GID (see the note below), and shares the
address-book cache — opening a detail screen from the list does not refetch.
Address model
formatAddress(address)— multiline display stringformatPhone(phone)—(555) 123-4567for 10-digit US numbersnormalizeAddress(raw, defaultAddressId?)— raw node → modeladdressBaseId(id)/sameAddressId(a, b)— token-safe comparison
Service API
'Not authenticated' without a session. Shopify-side rejections throw an
AddressUserError whose userErrors array keeps the code, field and
message for each problem, so a form can map messages to inputs.
