Data access priority for custom storefront components
Key Takeaway
Use data providers first, then Commerce Client APIs, and use custom Apex controllers only when those two aren't available or sufficient.
A custom storefront component can get its data in several ways, but the ways are not equal. Salesforce recommends a priority order: data providers first, then Commerce Client APIs (client-side Storefront APIs), and custom Apex controllers only when the first two fall short. The order avoids unnecessary server requests and keeps data consistent across the page.
How to choose what to build
When you bind a custom LWR storefront component to data, prefer out-of-the-box APIs in the priority order. You move down a level only when the level above isn't available or sufficient. One check comes first: whether you need a custom component at all.
- Check whether an out-of-the-box component with CSS overrides meets the need. Built-in components in the Experience Builder palette are optimized for both client-side and server-side rendering.
- If you still need a custom component, start with Priority 1: data providers.
- If data providers aren't available or sufficient, move to Priority 2: Commerce Client APIs.
- If Commerce Client APIs aren't available or sufficient either, move to Priority 3: Apex controllers.
So before you build a custom component backed by a custom Apex controller, confirm that no data provider, no Commerce Client API and no out-of-the-box component with CSS overrides already meets the need.