Composables
All composables provided by @avvyr/storefront-nuxt
useCart()
Reactive cart with SSR-safe useState. Token is persisted in a cookie and restored on load.
const {
cart, // Ref<StorefrontCart | null>
cartLoading, // Ref<boolean>
create,
get,
previewShared, // POS-shared carts, step 1: read-only proposal
redeemShared, // POS-shared carts, step 2: take over the cart
addItem,
removeItem,
setCustomer,
setCustomerType,
setShipping,
applyCode,
removeCode,
complete,
} = useCart()
POS shared cart handoff (two steps — viewing does not commit the customer):
// On /cart/:cartId/shared?t=<token>
const route = useRoute()
const { previewShared, redeemShared } = useCart()
// Step 1: show the proposal. Repeatable, consumes nothing.
const proposal = await previewShared(cartId, route.query.t as string)
// Step 2: on "Go to checkout" — the customer takes over the cart.
await redeemShared(cartId, route.query.t as string)
await navigateTo('/checkout')
useAuth()
Manages customer session state and persists tokens in cookies.
const {
customer, // Ref<CustomerProfile | null>
isAuthenticated, // Ref<boolean>
authLoading, // Ref<boolean>
login,
register,
sendMagicLink,
verifyMagicLink,
verifyMagicLinkCode,
logout,
getProfile,
updateProfile,
} = useAuth()
Auth middleware — protect a page with one line:
definePageMeta({ middleware: 'auth' })
Unauthenticated users are redirected to /login automatically.
useProductSearch(params) / useProductByHandle(handle) / useProductBySku(sku)
All product composables return a useAsyncData result and re-fetch reactively when params change.
// Search with reactive params
const searchParams = ref({ q: '', limit: 24 })
const { data, pending } = useProductSearch(searchParams)
// PDP
const { data: product } = useProductByHandle(route.params.handle)
useProductListing(params)
Combines search, filters, and facets for category/listing pages.
const { products, facets, total, pending, loadMore } = useProductListing({
categoryId: category.value?.id,
limit: 24,
})
useCategories() / useCategoryNav()
// Get a specific category
const { data: category } = useCategories().getByHandle(route.params.handle)
// Full nav tree for header menus
const { tree } = useCategoryNav()
useCheckout()
const { init, getConfirmation, loading } = useCheckout()
// On checkout page
const session = await init({ cartId: cart.value.id, provider: 'klarna', ... })
// On confirmation page
const { data: confirmation } = getConfirmation(route.params.reference)
useShipping()
const { options, loading, fetchOptions } = useShipping()
await fetchOptions({ cartId: cart.value.id, countryCode: 'SE', postalCode: '11120' })
useOrders() / useReturns() / useReviews()
const { orders, loadMore } = useOrders()
const { returns, create: createReturn } = useReturns()
const { reviews, statistics } = useReviews()
useMarket()
Active market resolved from URL path or domain.
const { marketId, market, switchMarket } = useMarket()
// market.value → { id, name, locale, currency, ... }
useCustomerType()
Persists B2B/B2C type in state.
const { customerType, setCustomerType } = useCustomerType()
// customerType: 'private' | 'business'
useStorefrontClient()
Returns the raw StorefrontClient instance. Use when you need direct access to the SDK outside a composable.
const client = useStorefrontClient()
const product = await client.products.getBySku('SKU-123')