Compatibility: Laioutr Core 0.19.3 and up
The @laioutr-app/commercetools package integrates a Laioutr-powered Nuxt app with Commercetools. It uses the Commercetools Platform API (products, categories, cart, product search with facets and sortings). The package registers with the Laioutr orchestr (queries, actions, links, component resolvers), and maps Commercetools images to the canonical media shape with provider commercetools for use with Nuxt Image.
Auth is either anonymous session (when a ctp-anon-token cookie is present) or client credentials (server-side only). The package creates or reuses the active cart per request and exposes canonical ecommerce capabilities so your UI can stay backend-agnostic.
Data flow:
useOrchestr() with canonical queries (e.g. ProductBySlugQuery)Install the Commercetools app into your project via the Laioutr Cockpit:
The Cockpit will add the module to your project and set up the necessary configuration.
To connect your Laioutr project to Commercetools, you need API credentials from the Commercetools Merchant Center.
my-project)| Region | API URL | Auth URL |
|---|---|---|
| Europe (AWS) | https://api.eu-central-1.aws.commercetools.com | https://auth.eu-central-1.aws.commercetools.com |
| North America (AWS) | https://api.us-central1.gcp.commercetools.com | https://auth.us-central1.gcp.commercetools.com |
| Australia (GCP) | https://api.australia-southeast1.gcp.commercetools.com | https://auth.australia-southeast1.gcp.commercetools.com |
laioutr-integration)manage_project:{projectKey} (required)manage_my_orders:{projectKey} (for anonymous cart/checkout)If you want cart functionality for guest users:
Configuration is managed through the Laioutr Cockpit App Config. The following options are set automatically when you configure the app. All five options are required.
| Option | Type | Description |
|---|---|---|
apiURL | string | Commercetools API base URL (e.g. https://api.eu-central-1.aws.commercetools.com). Default: EU Central 1. |
authURL | string | Commercetools Auth URL (e.g. https://auth.eu-central-1.aws.commercetools.com). Default: EU Central 1. |
projectKey | string | Commercetools project key. Default: laioutr-demo. |
clientId | string | API client ID with scope manage_project:{projectKey} (and anonymous sessions if you use cart/me). |
clientSecret | string | API client secret. Keep this secret and only use it on the server (the module stores it in private runtime config). |
For advanced setups or local development, you can configure the module directly in nuxt.config.ts:
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@laioutr-app/commercetools', '@laioutr-core/orchestr', '@nuxt/image'],
'@laioutr-app/commercetools': {
apiURL: process.env.CTP_API_URL ?? 'https://api.eu-central-1.aws.commercetools.com',
authURL: process.env.CTP_AUTH_URL ?? 'https://auth.eu-central-1.aws.commercetools.com',
projectKey: process.env.CTP_PROJECT_KEY!,
clientId: process.env.CTP_CLIENT_ID!,
clientSecret: process.env.CTP_CLIENT_SECRET!,
},
});
Use environment variables for clientId and clientSecret; never commit secrets to version control.
@commercetools/ts-client and @commercetools/platform-sdk. If the request has the anonymous token cookie (ctp-anon-token), it uses anonymous session flow so cart and me endpoints work. Otherwise it uses client credentials flow (server-only, no cart/me). The client is passed into the orchestr context as commercetoolsClient.ctp-anon-token and ctp-anon-refresh-token (httpOnly, secure, sameSite: strict, path: /). The first request without a token triggers a token fetch before running orchestr handlers.The package implements Laioutr’s canonical ecommerce types via the orchestr. The following lists what is available; for exact types and payloads, refer to @laioutr-core/canonical-types and the package source.
me().activeCart() or creates a new cart with me().carts().post() if none exists. Currency comes from clientEnv.currency. Returns { id: "" } if neither anonymous nor authenticated session is available.alias === "root" returns top-level categories (parent is not defined); otherwise looks up category by key and returns that category’s id. Returns { ids, total }.masterData.current(slug(locale = "…"))). Returns { id }.ids, total, availableFilters, availableSortings.type === "product" are resolved by SKU via product search; then addLineItem actions are applied (productId, variantId, quantity). Creates the cart if needed (same as GetCurrentCartQuery).sourceId (product id) → targetIds (master + variant SKUs).carts().get() with expand for discount codes.productProjections().get() with currency from clientEnv.Product and variant images from Commercetools are mapped to the canonical MediaImage type with provider: "commercetools" and sources[].src` set to the image URL (and optional width/height from \`dimensions\). The module installs @nuxt/image on prepare; use a Commercetools Nuxt Image provider if your setup requires it to serve or transform these URLs.
For the integration to work correctly, your Commercetools project needs:
key and slug fields set for menu queries to workThe app configures these facets by default:
| Facet | Attribute path |
|---|---|
| Price | variants.prices.centAmount |
| In Stock | variants.availability.isOnStock |
| Color | variants.attributes.search-color.key |
To customize facets for your product types, extend the configuration in defineCommercetools.
| Cookie | Purpose |
|---|---|
| ctp-anon-token | Anonymous session access token for Commercetools (me, cart). Set by the token cache when using anonymous session flow. |
| ctp-anon-refresh-token | Refresh token for the anonymous session. |
Without these cookies, the app uses client credentials only; GetCurrentCartQuery and cart actions will not have a customer cart and may return empty id or create one-off carts depending on implementation.
Symptom: GetCurrentCartQuery returns { id: "" }.
Cause: No anonymous session cookie is present, and client credentials flow cannot access me endpoints.
Solution:
ctp-anon-token cookie is being set (check browser DevTools → Cookies)Symptom: API calls fail with unauthorized or forbidden errors.
Possible causes:
clientId/clientSecretSolution:
manage_project:{projectKey}Symptom: Product queries return empty results.
Possible causes:
Solution:
en-US)Symptom: availableFilters is empty or missing expected facets.
Cause: Default facet configuration doesn't match your product type attributes.
Solution:
variants.attributes.search-color.key)Symptom: Users are logged out unexpectedly or carts reset.
Cause: Refresh token expired or cookie not persisting.
Solution:
Nimstrata Google Retail API
Developer documentation for the Laioutr Nimstrata app package. Add AI-powered search, recommendations, suggested search, and event tracking to your Laioutr frontend via the Nimstrata (Retail Connect) API, with Shopify integration.
Emporix
Developer documentation for the Laioutr Emporix app package. Connect your Nuxt frontend to Emporix via the Emporix API with anonymous or authenticated auth.