sfnext-state-management
Choose the right state mechanism in a Storefront Next project: loader and action data, useRouteLoaderData, URL state with useSearchParams, cookies and sessions, optimistic UI (fetcher.formData, useNavigation, useOptimistic), React context providers (BasketProvider, AuthProvider, wishlist, product-context), and small useSyncExternalStore stores such as the mini-cart store. Use for "where should this state live", "useBasket", "useAuth", "share state between components", "optimistic add to cart", "global client state", "hydration mismatch from a store", or "do I need Zustand". Do not use for fetching or mutating data (use storefront-next:sfnext-data-fetching), controlling loader re-runs (use storefront-next:sfnext-revalidation), or login flows and sessions (use storefront-next:sfnext-authentication).
Pinned to revision fe78868e0e70, so it is the text this page describes rather than whatever the author pushed since.
Files
- skills/sfnext-state-management/SKILL.md
- skills/sfnext-state-management/evals/trigger-evals.json
- skills/sfnext-state-management/references/PATTERNS.md
Every link opens the file at its source, pinned to the revision this page describes.