sfnext-data-fetching
Installation
SKILL.md
Data Fetching Skill
This skill covers server-side data fetching patterns in Storefront Next — loaders, actions, and the useScapiFetcher hook.
Overview
Storefront Next mandates server-only data loading. All SCAPI requests execute on the MRT server, never in the browser. Three mechanisms exist:
| Mechanism | When It Runs | Use Case |
|---|---|---|
loader |
Route navigation | Initial page data |
action |
Form submission | Mutations (add to cart, update profile) |
useScapiFetcher |
User interaction | On-demand fetching (search suggestions, infinite scroll) |
Loader Patterns
Loaders can be synchronous (returning promises for streaming) or async (awaiting critical data). Choose based on what the page needs: