Pular para o conteúdo principal

Location

location: AppLocation

The user's current location within the application, including the page type and URL. Each key in queries is a query parameter name; each value is that parameter's value.

PropertyTypeAlways presentDescription
urlstringYesThe current URL of the application.
pagePageYesThe current page type and its associated data.
queriesRecord<string, string>YesQuery parameters extracted from the URL.

Page (location.page) is a discriminated union: the shape of page.data depends on page.type. Use page.type to narrow the type before reading page.data.

page.typepage.data shapeDescription
"home"HomeHomepage (optional sections).
"checkout"CheckoutCheckout step and flow.
"product"ProductPageDataProduct detail and optional sections.
"category"Category and product listCategory and optional products.
"products"Category (id: 0) and product listAll-products page.
"search"Search and product listSearch query and optional products.
"account"AccountAccount page data.
"custom_page"CustomPageDataCustom page name.

Checkout (page.data when page.type === "checkout"):

PropertyTypeAlways presentDescription
stepstringYes"start", "payment", or "success".

Home (page.data when page.type === "home"): undefined or an object with optional sections (see WithSections).

ProductPageData (page.data when page.type === "product"):

PropertyTypeAlways presentDescription
productProductDetailsYesThe product being viewed.
sectionsSection<"product">[]NoOptional sections.

Category (used when page.type === "category" or "products"):

PropertyTypeAlways presentDescription
idnumberYesCategory id (0 for "products" = all products).
namestringYesCategory name.

Search (page.data when page.type === "search"):

PropertyTypeAlways presentDescription
qstringYesSearch query string.

WithProductList (category and search pages may include): optional products?: ProductDetails[].

WithSections<T> (home and product pages may include): optional sections?: Section&lt;T&gt;[].

CustomPageData (page.data when page.type === "custom_page"):

PropertyTypeAlways presentDescription
namestringYesCustom page name.

For the exact TypeScript definitions (including Page, AppLocation, ProductDetails, Section, Account, and all page data types), use the types from @tiendanube/nube-sdk-types.