Salta ai contenuti

@kotao/storefront

Il SDK di runtime del tema. I helper server vivono sull’entrypoint radice; i blocchi di UI sotto /react; utilità focalizzate sotto i propri subpath. Questa pagina è una mappa di entrypoint — la documentazione più profonda per simbolo viene generata in una release successiva.

Toolkit lato server usato dal tuo entry Worker e dai loader di route:

  • Context & client — createKotaoContext, createStorefrontClient: il contesto per richiesta che i tuoi loader raggiungono come context.storefront.
  • Cart — createCartHandler, CartForm azioni (CART_FORM_ACTIONS), applyOptimisticCartAction, helper cookie cart-id.
  • Caching — CacheShort, CacheLong, CacheNone, CacheCustom, createWithCache, generateCacheControlHeader.
  • SEO & routing — getSeoMeta, builder JSON-LD (productJsonLd, organizationJsonLd, …), storefrontRedirect, risposte sitemap/robots.
  • Localization — rilevamento locale (localeFromRequest, localizePath, stripLocalePrefixFromRequest), handler modulo di localizzazione.
  • Consent & analytics — encode/decode cookie consenso, createAnalyticsEmitter, getShopAnalytics.
  • Checkout — resolveCheckoutUrl, passaggio consent checkout, estrazione design-token.
  • Pagination — getPaginationVariables, getPaginationInfo, flattenConnection.

Componenti client e hook: Image, Money / useMoney, Seo, Pagination, MediaFile, CartForm + OptimisticInput / useOptimisticData, viste Analytics* + useAnalytics, ConsentBanner, ShopPayButton, impostazioni tema tramite ThemeSettingsProvider / useThemeSettings / useSectionSettings, e openSmartCart per il drawer cart della piattaforma.

Il binding React Router 8: getKotaoLoadContext (collega la richiesta Worker alle tue route) più re-exports compat defer / json.

Logica di selezione variante: getProductOptions, getSelectedVariant, getSelectedProductOptions, getAdjacentAndFirstAvailableVariants, useOptimisticVariant, useSelectedOptionInUrlParam.

imageUrl, imageSrcSet, buildImageAttrs — CDN image URLs with transforms, and complete <img> attribute sets (dimensions included, CLS-safe).

Il toolkit SEO standalone: getSeoMeta, builder JSON-LD, robotsResponse, sitemapResponse / sitemapIndexResponse, storefrontRedirect.

Plumbing Settings-as-data: fetchThemeSettings, resolveThemeSettings, mergeSettings / mergeSection, createThemeSettingsStore.

createStorefrontEditorBridge / createStorefrontEditorHostBridge — il bridge live-preview che l’editor tema Workspace usa per comunicare con il tuo tema.

/cart-documents (i documenti GraphQL cart), /storefront-api-types e /customer-account-api-types (tipi API generati).