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.
The module expects configuration under the key @laioutr-app/commercetools in nuxt.config.ts (or via runtimeConfig). 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). |
// 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 (or a similar secret source) for clientId and clientSecret in production; do not commit them.
@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.
projectKey, apiURL, and authURL for your region.manage_project:{projectKey}. For cart and me (active cart, anonymous sessions), ensure anonymous sessions are allowed for the project and that the client is used only server-side with the provided client secret.variants.prices.centAmount, variants.availability.isOnStock, variants.attributes.search-color.key). Adjust or extend in defineCommercetools to match your product types and searchable attributes.| 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.
@laioutr-app/commercetools and @laioutr-core/orchestr (and @nuxt/image if using images) to Nuxt modules.apiURL, authURL, projectKey, clientId, clientSecret under @laioutr-app/commercetools (e.g. from env).manage_project:{projectKey} and that anonymous sessions are enabled if you use cart/me.provider: "commercetools" for product/variant images; configure Nuxt Image with a Commercetools provider if required.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.