Cert++
Close

Imperative APIs, wire adapters, and Storefront Actions compared

Key Takeaway

Use a Wire Adapter to show data that updates automatically, an Imperative API to run a process and use its outcome, and a Storefront Action to update closely related components from a UI click.

B2B stores built with LWR templates support Storefront APIs, which let custom Lightning Web Components (LWCs) read store data and run processes. There are three kinds: Imperative APIs, Wire Adapters and Storefront Actions. They differ in how and when they get data, so your choice depends on what the component needs to do. A shared State Management layer keeps related components in sync.

What Storefront APIs do

Storefront APIs connect custom LWCs, such as headers, footers and banners, with data. They also run processes like adding a product to a wishlist or cart or applying a coupon to an order. They fetch and display data for Commerce, Platform and CMS products.

Compared with components built on platform UI APIs and Aura controllers, Storefront APIs offer four advantages:

  • They apply guardrails such as buyer entitlement automatically.
  • They avoid requesting the same data twice by using browser, CDN and server cache layers.
  • They combine data from sources like catalogs and price books. They also run business logic such as fetching a product price or checking promotion eligibility.
  • They keep the customer experience consistent across components.

AppContextAdapter and SessionContextAdapter show how Storefront APIs avoid fetching the same data more than once. They read from their stores first and call the context API only if the data has not loaded yet.

Salesforce Accredited B2B Commerce Developer Professional Study Guide

Checklist progress

0/124Learned

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other Salesforce Accredited B2B Commerce Developer Professional studiers. 757 members and growing.