Data Fetching and Loading States Differences with PWA Kit
PWA Kit follows a fetch-on-render model where hooks request data during component render and expose manual loading flags. Storefront Next follows fetch-then-render with route loaders that gather data before component rendering, enabling Suspense and streaming patterns more naturally. This moves data concerns out of presentation components and simplifies loading orchestration.
PWA Kit and Storefront Next handle loading states with different models. PWA Kit relies on manual conditional rendering, while Storefront Next uses React Suspense for declarative loading boundaries. PWA Kit’s approach gives explicit control through React Query’s isLoading flags and conditional rendering. Storefront Next’s Suspense-based approach keeps components focused on rendering with data while boundaries handle loading automatically. That reduces boilerplate and enables streaming, but it requires understanding Suspense patterns and React 19’s use() hook.
| Aspect | PWA Kit | Storefront Next |
|---|---|---|
| Data Location | Inside components (hooks) | Outside components (loaders) |
| Discovery | Automatic (hook scanning) | Explicit (route exports) |
| Feature | PWA Kit | Storefront Next |
|---|---|---|
| SSR Approach | React Query auto-discovery | Loader functions |
| Client Navigation | React Query refetch | Client loader |
| Legacy Support | getProps static method | N/A |
| Caching | React Query cache | Manual / React Router |
| Feature | PWA Kit | Storefront Next |
|---|---|---|
| Pre-fetch Processing | Express middleware | React Router middleware |
| Shared State | Express res.locals | Router context |
| Request Access | Full Express req/res | Fetch API Request |
| Aspect | PWA Kit | Storefront Next |
|---|---|---|
| Approach | Manual conditional rendering | Declarative Suspense boundaries |
| Loading detection | isLoading flags from hooks | use() hook suspends on pending promises |
| Skeleton display | Explicit if (isLoading) checks | Automatic via Suspense fallback |
| Multiple regions | Manual state tracking per region | Multiple <Suspense> boundaries |
| Navigation transitions | keepPreviousData option | getPageKey + shouldRevalidate |
| Code splitting | @loadable/component fallback | React Router automatic splitting |
| Skeleton styling | Chakra <Skeleton> component | Tailwind animate-pulse |
| Streaming | Limited | Native promise streaming |
PWA Kit — imperative:
Storefront Next — declarative:
PWA Kit can experience client-side waterfalls when data-fetching hooks depend on each other:
Storefront Next enables streaming where data resolves as it’s ready:
PWA Kit and Storefront Next have these data fetching capabilities.
- Server-side rendering.
- Fetching data from any data source.
- Setting response headers.
- Middleware/pre-processing capabilities.
When converting your storefront from PWA Kit to Storefront Next, keep these tips in mind.
- Move data fetching to loaders: Extract
useQuerycalls intoloaderfunctions. - Replace React Query: Use loader returns instead of hooks.
- Conditional rendering → Suspense: Replace
if (isLoading)patterns with Suspense boundaries and thecreatePagefactory. - Update loading states: Replace
isLoadingconditionals with Suspense fallbacks. keepPreviousData→shouldRevalidate: Move “keep old data visible” logic from React Query options to router revalidation control.- Loading spinners → skeleton fallbacks: Convert inline loading spinners to skeleton components in Suspense fallbacks.
- Multiple loading states → multiple boundaries: Split single-page loading into independent Suspense regions for granular streaming.
- Convert middleware: Express middleware becomes React Router middleware.
- Update request access: Use Fetch API
Requestinstead of Expressreq.