sfnext-data-fetching
Load and mutate data in a Storefront Next project: route loaders that call SCAPI through createApiClients from @/lib/api-clients.server, critical versus streamed (deferred) data, createBasketAction and BasketAction for cart actions, createActionError and ErrorCode, data() responses, useFetcher and the useScapiFetcher hook with its server allowlist, request-scoped dedupe and MRT timeouts, non-personalized SCAPI responses, shopper context, and custom API clients. Use for "fetch products in a loader", "stream data", "add a cart action", "call SCAPI from a component", "resource route", "NormalizedApiError", or "loader blocks the page". Do not use for route files or links (use storefront-next:sfnext-routing), when loaders re-run after actions (use storefront-next:sfnext-revalidation), Suspense/LCP tuning (use storefront-next:sfnext-performance), or defining SCAPI custom APIs (use storefront-next:sfnext-scapi).
Pinned to revision fe78868e0e70, so it is the text this page describes rather than whatever the author pushed since.
Files
- skills/sfnext-data-fetching/SKILL.md
- skills/sfnext-data-fetching/evals/trigger-evals.json
- skills/sfnext-data-fetching/references/ACTIONS.md
- skills/sfnext-data-fetching/references/API-CLIENTS.md
- skills/sfnext-data-fetching/references/LOADERS.md
- skills/sfnext-data-fetching/references/SCAPI-FETCHER.md
Every link opens the file at its source, pinned to the revision this page describes.