Storefront APIs
B2B and D2C stores built with LWR templates support Storefront APIs that help you build custom Lightning Web Components (LWCs) including headers, footers, and banners. Storefront APIs connect LWCs with data and execute processes, like adding a product to a wishlist or a cart, or applying a coupon to an order. Storefront APIs simplify LWC creation and help integrate components into larger page contexts.
Required Editions |
---|
Available in: Lightning communities accessed through Lightning Experience in Enterprise, Unlimited, and Developer editions. |
Implementing components with Storefront APIs delivers distinct advantages over those relying on platform UI APIs and Aura controllers:
- Security - Storefront APIs automatically apply guardrails, such as buyer entitlement, that protect transactions and personalize customer journeys, with minimum risk.
- Performance and Scalability - Storefront APIs ensure that the same data is not requested and retrieved multiple times. Optimized to use multiple cache layers (browser, CDN, server), Storefront APIs retrieve information efficiently. Storefront Actions, for example, are designed to fetch data from the nearest available source.
- Convenience - Storefront APIs aggregate data from multiple sources and objects, like catalogs, or price books, and can execute business logic (fetch a product price, determine promotion eligibility).
- UI Cohesiveness - Components that implement Storefront APIs help ensure a consistent, cohesive customer experience. Cart components that use Wire Adapters, for example, achieve real-time reactivity: adding an item to a cart automatically updates the cart icon in the header.
The Storefront APIs fetch and display data for Commerce, Platform, and CMS products and include Imperative APIs, Wire Adapters, and Storefront Actions. Each of these differ in how and when they retrieve data for your component. A State Management layer provides access to hosted data via REST APIs and also coordinates operations that engage and update builder components. For example, when a buyer adds a product to the cart via a Storefront API, the State Management layer assures that this updates the list of cart items and the cart status icon. Taken together, the Storefront APIs provide a comprehensive framework for a dynamic shopping experience.
- Imperative APIs are process-oriented functions that, for example, call a Connect API method (POST, PUT, PATCH) to update data and return an outcome. Imperative calls typically retrieve hosted data when triggered by a page load or button click. Imperative APIs prompt updates to related entities including Wire Adapters, all orchestrated via State Management.
- Wire Adapters specify a GET method to call and retrieve data from a hosted data source. The adapter automatically updates properties in the LWC when hosted source data changes. When the LWC loads or updates, it executes the adapter call and retrieves the data in real time. For more information, see Understand the Wire Service.
- Storefront Actions are events, such as adding an item to a cart or using a filter to search on a product variant, that trigger updates to closely-related LWCs. Unlike actual backend API endpoint communication, Storefront Actions react to UI clicks more responsively, by making changes to related page-level components in chain-of-sequence fashion within a proximate scope. When a customer clicks a quantity selector component, for example, a
createCartItemsLoadAction
refreshes the quantity displayed in the cart. Tight data binding ensures that the triggered operation gets and sets data from the closest source. That said, Storefront Actions can result in calls (via Wire Adapters or Imperative APIs) to Rest API endpoints
These tables provide information about custom component Imperative APIs and adapters.
In B2B and D2C stores, imperative Checkout APIs intentionally strip any 'name' properties on ContactPointAddress, CartDeliveryGroup, and OrderDeliveryGroup objects before initiating the request to Checkout Connect Endpoints. The best way to work around this issue is to create custom Apex triggers on insert or update for the relevant objects to update DeliverToName based on your stores globalization requirements. We recommend using the same behavior as the out of the box checkout component and only pass ContactPointAddress ID when calling the updateShippingAddress Imperative API.
Namespace/Bundle | Name/Interface | Product | API Version | Description | Associated Endpoint |
---|---|---|---|---|---|
commerce/activitiesApi | Commerce | 55.0 | Triggers the addToCart activity when a shopper adds a product to the cart. If you replace the Product Detail Purchase Options component with a custom component, implement the addToCart activity to ensure that Commerce Einstein Recommendations use cases generate results based on shopper or buyer view behavior. | Einstein Recommendations API | |
commerce/activitiesApi | Commerce | 55.0 | Triggers the clickReco activity when a recommended product is clicked and the customer is taken to the product detail page. Implement this activity when building a custom Commerce Einstein recommendations component. | Einstein Recommendations API | |
commerce/activitiesApi | Commerce | 55.0 | Triggers the viewProduct activity when a shopper views a Product Detail page. Don’t fire if a product is displayed via a recommendation, search result, or any other means. If you replace the Product Detail Purchase Options component with a custom component, implement the viewProduct activity to ensure that Commerce Einstein Recommendations use cases generate results based on shopper or buyer view behavior. | Einstein Recommendations API | |
commerce/activitiesApi | Commerce | 55.0 | Triggers the viewReco activity when a recommendation is displayed to the customer. Implement this activity when building a custom Commerce Einstein recommendations component. If you calculate a recommendation but don’t show it to the customer—for example, it doesn’t have as many results as you like—don’t fire this activity. | Einstein Recommendations API | |
commerce/cartApi | Commerce | 57.0 | Adds an item to a cart. | Commerce Webstore Cart Items | |
commerce/cartApi | Commerce | 57.0 | Adds multiple items to the cart. | Commerce Webstore Cart Items | |
commerce/cartApi | Commerce | 57.0 | Applies a coupon to the cart. | Commerce Webstore Cart Items | |
commerce/cartApi | Commerce | 57.0 | Deletes an applied coupon from the cart. | Commerce Webstore Cart Items | |
commerce/cartApi | Commerce | 57.0 | Deletes an active/current cart. | Commerce Webstore Cart Items | |
commerce/cartApi | Commerce | 57.0 | Deletes an item from the cart. | Commerce Webstore Cart Items | |
commerce/cartApi | Commerce | 58.0 | Refreshes the cart summary. | Commerce Webstore Cart Items | |
commerce/cartApi | Commerce | 58.0 | Sets the isProcessing status field of the cart to the provided processing state. | Commerce Webstore Cart Items | |
commerce/cartApi | Commerce | 57.0 | Updates the item quantity in the cart. | Commerce Webstore Cart Items | |
commerce/checkoutApi | Commerce | 56.0 | Authorizes a tokenized payment for a checkout session. | Commerce Webstore Checkout | |
commerce/checkoutApi | Commerce | 60.0 | Returns true if the supplied checkout status is complete and will accept additional parameters | Commerce Webstore Checkout | |
commerce/checkoutApi | Commerce | 56.0 | Creates a contact point address record. This API doesn’t affect the checkout session. | Commerce Webstore Checkout | |
commerce/checkoutApi | Commerce | 57.0 | Loads the checkout session or error and saves it in the store for access by the wire adapter. | Commerce Webstore Checkout | |
commerce/checkoutApi | Commerce | 57.0 | Publishes an updated checkout session state to the store so changes can be propagated by the wire adapter to subscribed listeners. Passing an Error replaces the checkout state and checkout ID with the error state. Passing null clears the published data cache. Returns the passed in data unmodified. | Commerce Webstore Checkout | |
commerce/checkoutApi | Commerce | 57.0 | Calls notifyCheckout with supplied data. Additionally, when state indicates an async computation in progress (httpStatus is 202), it calls loadCheckout to poll until async tasks complete. Automatically triggers a cart summary refresh if needed. | Commerce Webstore Checkout | |
commerce/checkoutApi | Commerce | 56.0 | Finalizes the order, completing the active checkout session. | Commerce Webstore Checkout | |
commerce/checkoutApi | Commerce | 56.0 | Sends a client-side authorization result to the server. | Commerce Webstore Checkout | |
commerce/checkoutApi | Commerce | 56.0 | Restarts an active checkout process. Before you use this API, clear all cached checkout and address data to prepare for a new “active” session. Clear cache is required anytime the previous checkout session becomes invalid. Attempts to use other checkout APIs after the previous session become invalid and fail until the restart is called. | Commerce Webstore Checkout | |
commerce/checkoutApi | B2B Commerce | 57 | Sends an authenticated buyer's simple purchase order number to the server. | Commerce Webstore Checkout | |
commerce/checkoutApi | Commerce | 56.0 | Updates the guest contact information in the active checkout session. | Commerce Webstore Checkout | |
commerce/checkoutApi | Commerce | 56.0 | Updates an existing contact point address record. This API doesn’t affect the checkout session. | Commerce Webstore Checkout | |
commerce/checkoutApi | Commerce | 56.0 | Updates the delivery method for the default delivery group in the active checkout session, and updates the cart summary. | Commerce Webstore Checkout | |
commerce/checkoutApi | Commerce | 56.0 | Updates the cached guest email value that’s shared between components. This API doesn’t affect the checkout session. | Commerce Webstore Checkout | |
commerce/checkoutApi | Commerce | 56.0 | Updates the shipping address for the default delivery group in the active checkout session. | Commerce Webstore Checkout | |
commerce/checkoutApi | Commerce | 57.0 | Returns a resolved promise immediately if the checkout status is complete. Otherwise, the returned promise resolves after the checkout status becomes complete or errors. | Commerce Webstore Checkout | |
commerce/contextApi | Commerce | 53.0 | Get application-context-specific data. | Commerce Webstore Application Context | |
commerce/contextApi | Commerce | 53.0 | Get session-context-specific data. | Commerce Webstore Application Context | |
commerce/myAccountApi | Commerce | 54.0 | Create an account address. | Commerce Webstore Account Address | |
commerce/myAccountApi | Commerce | 54.0 | Delete an account address. | Commerce Webstore Account Address | |
commerce/myAccountApi | Commerce | 54.0 | Update an account address. | Commerce Webstore Account Address | |
commerce/myAccountApi | Commerce | Reset a password. | Commerce Webstore Account Address | ||
commerce/myAccountApi | Commerce | 59.0 | Update an existing account profile. | Commerce Webstore Account Address | |
commerce/orderApi | Commerce | 57.0 | Commerce Checkout Order | ||
experience/cmsEditorApi | CMS | 54.0 | Updates the property to be updated in content form. Then calls back after the form is updated. | CMS Content | |
experience/effectiveAccountApi | const accountId = effectiveAccount.accountId // To read the effective account Id from session storage. const accountName = effectiveAccount.accountName // To read the effective account name from session storage. }); | Commerce | 57 | Sets the account name and id in session storage. | B2B and D2C Commerce Resources |
Namespace/Bundle | Adapter | Product | API Version | Description | Associated Endpoint |
---|---|---|---|---|---|
commerce/cartApi | CartAdapter | Commerce | 60.0 | Retrieves total count of items in the cart. | Commerce Webstore Cart |
commerce/cartApi | CartCouponsAdapter | Commerce | 55.0 | Retrieves cart coupon information, loads cart coupons. | Commerce Webstore Cart Coupons |
commerce/cartApi | CartItemsAdapter | Commerce | 53.0 | Fetches and loads cart items, supports sorting. | Commerce Webstore Cart Items |
commerce/cartApi | CartPromotionsAdapter | Commerce | 55.0 | Retrieves and loads cart-level and item promotion information when eligible items are added or updated. | Commerce Webstore Cart Promotions |
commerce/cartApi | CartSummaryAdapter | Commerce | 53.0 | Fetches current cart totals data from rollup calculators for CartBadge, CartSummary, Checkout, and other components. | Commerce Webstore Cart |
commerce/cartApi | CartStatusAdapter | Commerce | 58.0 | Retrieves status information about a cart, including whether a cart is processing, whether a cart is ready for checkout, and whether guest cart or checkout access is enabled. | Commerce Webstore Cart |
commerce/checkoutApi | CheckoutAddressAdapter | Commerce | 56.0 | Uses multiple calls to aggregate results for the get-address-list API. This adapter is a deeper get-address-list API wrapper. | Commerce Webstore Checkout |
commerce/checkoutApi | CheckoutGuestEmailAdapter | Commerce | 56.0 | Retrieves guest email info value from the store. | Commerce Webstore Checkout |
commerce/checkoutApi | CheckoutInformationAdapter | Commerce | 56.0 | Retrieves data from CheckoutStore, guest email info value from the store, the deliveryGroup, and the first shippingInstructions in the store. Called one time at startup and then whenever the data store updates. | Commerce Webstore Checkout |
commerce/contextApi | AppContextAdapter | Commerce | 53.0 | Retrieves app context data from the AppContext store. If data hasn’t been loaded, the adapter calls the application context API. | Application Context |
commerce/contextApi | SessionContextAdapter | Commerce | 53.0 | Retrieves session context data from the SessionContext store. If data hasn’t been loaded, the adapter calls the session context API. | Session Context |
commerce/orderApi | OrderAdapter | Commerce | 57.0 | Called when a buyer views the order summary of an order. Retrieves an order summary, including fields, based on the effective account ID. | Commerce Webstore Order Summary |
commerce/orderApi | OrdersAdapter | Commerce | 57.0 | Called when a buyer views their order history page. Retrieves order summaries, including fields, for the buyer associated with the storefront. | Commerce Webstore Order Summaries |
commerce/orderApi | OrdersAdjustmentsAdapter | Commerce | 57.0 | Called when a buyer views the order summary of an order. Retrieves adjustments for an order summary. | Commerce Webstore Order Summary, Adjustments |
commerce/orderApi | OrderDeliveryGroupsAdapter | Commerce | 57.0 | Called when a buyer views the order summary of an order. Retrieves an order delivery group. | Commerce Webstore Order Delivery Groups |
commerce/orderApi | OrderItemsAdapter | Commerce | 57.0 | Called when a buyer views the order summary of an order. Retrieves order items, including fields. | Commerce Webstore Order Items |
commerce/orderApi | OrderItemsAdjustmentsAdapter | Commerce | 57.0 | Called when a buyer views the order summary of an order. Retrieves adjustments for order items. | Commerce Webstore Order Items, Adjustments |
commerce/orderApi | OrderSummaryLookupAdapter | Commerce | 58.0 | Retrieves details about an OrderSummary for a guest shopper or a registered buyer | Commerce Webstore Order Summary Lookup |
commerce/productApi | ProductAdapter | Commerce | 53.0 | Called when the product is loaded. Retrieves product information from the store. | Commerce Webstore Product |
commerce/productApi | ProductCategoryAdapter | Commerce | 53.0 | Retrieves category information, including fields and related media. | Commerce Webstore Product Category |
commerce/productApi | ProductCategoryHierarchyAdapter | Commerce | 53.0 | Retrieves a list of product category information, including fields and related media, based on the parent product category Id. | Commerce Webstore Product Categories Children |
commerce/productApi | ProductCategoryPathAdapter | Commerce | 53.0 | Retrieves the category path from the root category to the current category. | Commerce Webstore Product Category Path |
commerce/productApi | ProductCategoryPathAdapter | Commerce | 53.0 | Retrieves the category path from the root category to the current category. | Commerce Webstore Product Category Path |
commerce/productApi | ProductChildrenAdapter | Commerce | 57.0 | Retrieves child product information including pricing, inventory, and promotional pricing. Based on the parent product category ID. | [Commerce Webstore Product Children |
commerce/productApi | ProductPricingAdapter | Commerce | 53.0 | Called when the product is loaded. Retrieves tiered pricing information for a given product. | Commerce Webstore Pricing Product |
commerce/productApi | ProductSearchAdapter | Commerce | 57.0 | Retrieves products by search parameters. | Commerce Webstore Product Search |
commerce/productApi | ProductTaxAdapter | Commerce | 57.0 | Retrieves tax information for a given product. | Commerce Webstore Taxes |
commerce/recommendationsApi | ProductRecommendationsAdapter | Commerce | 55.0 | Returns Einstein product recommendations. Import it from the einsteinAPI module within the commerce namespace (commerce/einsteinAPI ) and then declare its required parameters with the @wire decorator. | B2C Commerce Einstein Product Recommendations API |
Namespace/Bundle | Wire Adapter | Product | API Version | Description | Associated Endpoint |
---|---|---|---|---|---|
experience/navigationMenuApi | getNavigationMenu | Platform | 54.0 | Retrieves the items for a navigation menu in an Experience Cloud site. | Navigation Menu Items |
experience/cmsDeliveryApi | getContent | CMS | 54.0 | Retrieves published content from an enhanced CMS workspace to use in a custom Lightning web component for an enhanced LWR site. | CMS Delivery Content |
experience/cmsEditorApi | getContext | CMS | 54.0 | Retrieve metadata about the content item in the CMS content editor. | CMS Content |
experience/cmsEditorApi | getContent | CMS | 54.0 | Retrieve the title, urlName, and contentBody of the content item based on the content type: image, news, document, or custom content. | CMS Content |
Storefront Actions are centrally combined in the component bundle commerce/actionApi
. The table shows the factory methods for this bundle.
Category | Name | Product | API Version | Description | Properties | actionApi Source |
---|---|---|---|---|---|---|
Cart | createCartItemAddAction | Commerce | 58.0 | Returns an Action that triggers an add-item-to-cart operation from the closest applicable Data Provider. | productId: stringquantity?: number | Commerce Webstore Cart Items |
Cart | createCartItemUpdateAction | Commerce | 58.0 | Returns an Action that triggers an update to cart contents operation from the closest applicable Data Provider. | cartItemId: stringquantity: number | Commerce Webstore Cart Items |
Cart | createCartItemDeleteAction | Commerce | 58.0 | Returns an Action that triggers a remove-item-in-cart operation from the closest applicable Data Provider. | cartItemId: string | Commerce Webstore Cart Items |
Cart | createCartItemsAddAction | Commerce | 58.0 | Returns an Action that triggers an add items in cart operation from the closest applicable Data Provider. | items: Record<string, number> | Commerce Webstore Cart Items |
Cart | createCartItemsLoadAction | Commerce | 58.0 | Returns an Action that triggers a load more cart items operation from the closest applicable Data Provider. | Commerce Webstore Cart Items | |
Cart | createCartSortUpdateAction | Commerce | 58.0 | Returns an Action that triggers an update cart sort order operation from the closest applicable Data Provider. | sortOrder?: 'CreatedDateDesc' | 'CreatedDateAsc' | 'NameDesc' | 'NameAsc' | Commerce Webstore Cart Items |
Cart | createCartStatusUpdateAction | Commerce | 58.0 | Returns an Action that triggers an update cart status operation from the closest applicable Data Provider. | status?: { isProcessing?: boolean; isReadyForCheckout?: boolean; isGuestCartEnabled?: boolean; isGuestCheckoutEnabled?: boolean;} | Commerce Webstore Cart Items |
Cart | createCartClearAction | Commerce | 58.0 | Returns an Action that triggers a clear cart operation from the closest applicable Data Provider. | Commerce Webstore Cart Items | |
Cart | createCartInventoryReserveAction | Commerce | 59.0 | Returns an Action that triggers a reserve inventory for cart items operation from the closest applicable Data Provider. | Commerce Webstore Cart Items | |
Checkout | createCheckoutAddressesCreateAction | Commerce | 58.0 | Returns an Action that triggers a checkout addresses create operation from the closest applicable Data Provider. | address: { name?: string; firstName?: string; lastName?: string; companyName?: string; street?: string; city?: string; postalCode?: string; region?: string; country?: string; addressId?: string; id?: string; fields?: unknown; geocodeAccuracy?: string; isDefault?: boolean; addressType?: string; label?: string;} | checkout ActionApi |
Checkout | createCheckoutAddressesPageChangeAction | Commerce | 58.0 | Returns an Action that triggers a checkout addresses page change from the closest applicable Data Provider. | total: number | Commerce Webstore Checkout |
Checkout | createCheckoutAddressesUpdateAction | Commerce | 58.0 | Returns an Action that triggers a checkout addresses update from the closest applicable Data Provider. | address: { name?: string; firstName?: string; lastName?: string; companyName?: string; street?: string; city?: string; postalCode?: string; region?: string; country?: string; addressId?: string; id?: string; fields?: unknown; geocodeAccuracy?: string; isDefault?: boolean; addressType?: string; label?: string;} | Commerce Webstore Checkout |
Checkout | createCheckoutFinalizeAction | Commerce | 58.0 | Returns an Action that triggers a finalize action from the closest applicable Data Provider. | Commerce Webstore Checkout | |
Checkout | createCheckoutPlaceOrderAction | Commerce | 58.0 | Returns an Action that triggers a place order action from the closest applicable Data Provider. | Commerce Webstore Checkout | |
Checkout | createCheckoutUpdateFormAction | Commerce | 58.0 | Returns an Action that triggers a checkout update from the closest applicable Data Provider. | * applicable {@link DataProvider}. | Commerce Webstore Checkout |
Common | createCommonQuantityUpdateAction | Commerce | 59.0 | Returns an Action that triggers an update quantity from the closest applicable Data Provider. | quantity: number | Commerce Webstore Cart Item |
Coupon | createCouponApplyAction | Commerce | 58.0 | Returns an Action that triggers an apply coupon from the closest applicable Data Provider. | couponId: string | Commerce Webstore Cart Promotions |
Coupon | createCouponDeleteAction | Commerce | 58.0 | Returns an Action that triggers a delete coupon from the closest applicable Data Provider. | couponId: string | Commerce Webstore Cart Promotions |
Order | createOrderAccessValidateAction | Commerce | 59.0 | Returns an Action that triggers an order summary access validate from the closest applicable Data Provider. | verificationDetails: { orderSummaryIdOrRefNumber?: string; fields?: string[] | null; excludeAdjustments?: boolean | null; excludeAdjustmentAggregates?: boolean | null; excludeLineItems?: boolean | null; excludeDeliveryGroups?: boolean | null; email?: string | null; lastName?: string | null; phoneNumber?: string | null;} | Commerce Webstore Order Summary |
Product | createProductQuantityUpdateAction | Commerce | 58.0 | Returns an Action that triggers an update product quantity from the closest applicable Data Provider. | productId: stringquantity: number | Commerce Webstore Order Summary |
Product | createProductVariantUpdateAction | Commerce | 58.0 | Returns an Action that triggers an update product variant from the closest applicable Data Provider. | options: string[]isValid: boolean | CMS Contents Variant |
Product | createProductSubscriptionUpdateAction | Commerce | 59.0 | Returns an Action that triggers an update product subscription from the closest applicable Data Provider. | productSellingModelId: stringsubscriptionTerm?: number | null | Subscription |
Search | createSearchSortUpdateAction | Commerce | 58.0 | Returns an Action that triggers an update search sort order from the closest applicable Data Provider. | sortRuleId?: string | Commerce Webstore Product Search |
Search | createSearchFiltersUpdateAction | Commerce | 58.0 | Returns an Action that triggers an update search filters from the closest applicable Data Provider. | refinements?: ProductSearchRefinement[]; categoryId?: string; page?: number; mruFacet?: SearchFacetData;} | Commerce Webstore Product Search |
Search | createSearchFiltersClearAction | Commerce | 58.0 | Returns an Action that triggers a clear search filters from the closest applicable Data Provider. | Commerce Webstore Product Search | |
Wishlist | createWishlistItemAddAction | Commerce | 58.0 | Returns an Action that triggers an add items to wishlist from the closest applicable Data Provider. | productId: string | Commerce Webstore Wishlists |
Wishlist | createWishlistItemDeleteAction | Commerce | 58.0 | Returns an Action that triggers an delete items to wishlist from the closest applicable Data Provider. | wishlistItemId: string | Commerce Webstore Wishlists |