Skip to Content

useAccount

The useAccount hook exposes the platform’s account URLs, for linking to the account pages.

Login, signup, profile and orders are platform pages rendered outside the theme (by platform-web), not by your theme. Link to them with a plain <a> tag (a full page load) using the urls below — the theme never renders account UI or calls auth APIs itself.

Usage

const {urls} = useAccount() // e.g. in a header account menu — plain anchors, since these leave the theme SPA: <a href={urls.login}>Login</a> <a href={urls.orders}>Orders</a> <a href={urls.logout}>Logout</a>

In development the account pages show a dev notice; /account/login offers a dev login that signs in the fixtures/user.js customer (see Sample data), and urls.logout signs out again — so useUser()-driven UI is fully testable locally.

Parameters

No parameters

Return Values

NameTypeDescription
urlsobjectThe platform account page URLs — see below.

urls

NameTypeDescription
loginstringLogin page — `/account/login`
signupstringSignup page — `/account/signup`
logoutstringLogout — `/account/logout`
accountstringAccount/profile — `/account`
ordersstringOrder history — `/account/orders`