Data overview

Which hook or loader gives you the store, theme, product, user and cart objects, and the rules for reading them safely.

Use this page when you know what data you need on screen and want to find the hook that gives it to you, and the page that lists every field.

Where each object comes from

ObjectWhere you get itPage
StoreuseStore()Store data
ThemeuseTheme()Theme data
ProductRoute loader data, kept live with useProduct()Product data
UseruseUser()User data
CartThe cart API after the SDK gives you the cart idCart data
WishlistuseWishlist() (product ids only)useWishlist
Translations and languageuseTranslation()useTranslation
Prices as textuseMoney()Shared types
Category, brand, menu, page, breadcrumb, paginationRoute loader data and the API modulesShared types

The types are exported from @salla.sa/twilight-theme-engine/types, so you can type your own props:

app/components/product/Title.tsx
import type { Product } from '@salla.sa/twilight-theme-engine/types';

export function Title({ product }: { product: Product }) {
  return <h1>{product.name}</h1>;
}

Three ways data reaches a component

  1. Hooks such as useStore and useTheme read data the engine loaded at the root of the app. It is there on the server and in the browser.
  2. Route loader data arrives as props or through the route's loader hook (the product page, a category page). See Loading data.
  3. API modules (@salla.sa/twilight-theme-engine/api/...) fetch data on demand, usually through React Query. See API modules.

Rules for reading data

Guests and missing data are normal. A customer who is not signed in has no user, so useUser().data is null. Optional fields (a field marked ? in the tables) can be absent, and category, brand or image can come back with empty values. Write product.brand?.name, not product.brand.name.

Money has two shapes. Most prices on a product are plain numbers, but some are objects { amount, currency, formatted? }. Cart lines can be either. Read the number with a small helper and format it with useMoney. Details in Shared types.

Ids differ by object. Products, cart lines and brands use numeric ids, categories also carry a short string id ("QlayPG") next to the number (id_), and cart ids are strings in the cart object but numbers in the API call. Do not compare ids of different objects, and do not assume a type, check it in the table.

Know where it runs. Store, theme and loader data exist in the server HTML. User, cart and wishlist belong to the customer's browser (their token and cart id), so render a guest or empty state first and let the real data fill in. A component that reads them must not break when they are absent.

Next

On this page