Routing Differences with PWA Kit
PWA Kit uses React Router 5 with programmatic route arrays and manual splitting patterns. Storefront Next uses React Router 7 file-based routing with native nested layouts, typed loaders/actions, and automatic route-level splitting. Migrating generally means converting centralized route configuration into route files and moving route data logic into exports.
| Aspect | PWA Kit | Storefront Next |
|---|---|---|
| Router Version | React Router 5 | React Router 7 (framework mode) |
| Route Definition | Programmatic (array in routes.jsx) | File-based (files in routes/) |
| Code Splitting | Manual via @loadable/component | Automatic per route file |
| Data Fetching | Inside components (hooks) | Outside components (loader/clientLoader) |
| Loading States | Manual isLoading flags | Declarative via Suspense |
| Nested Layouts | Manual component composition | Built-in via <Outlet /> |
| Resource Routes | Express routes in ssr.js | Action files (action.*.tsx) |
| Multi-Site URLs | configureRoutes() expansion | TBD / handled differently |
| Type Safety | JavaScript | TypeScript with typed loaders |
PWA Kit:
Storefront Next:
PWA Kit (React Router 5):
Storefront Next (React Router 7):
- Dynamic Parameters: Both use
:paramsyntax (PWA Kit in path string, Storefront Next in file name with$). - Catch-All Routes: Both support wildcard routes (
*in PWA Kit,$.tsxin Storefront Next). - Programmatic Navigation: Both provide hooks for imperative navigation.
- Route Parameter Access: Both provide
useParams()hook for accessing URL parameters.
- Route File Creation: Each route in
routes.jsxbecomes a separate file insrc/routes/. - Naming Convention: Learn the flat routes naming pattern (
$for params,.for nesting). - Data Fetching: Move data fetching from component hooks to
loader/clientLoaderexports. - Layout Routes: Use layout routes with
<Outlet />instead of manual nesting. - Resource Routes: Convert Express API routes to
action.*.tsxfiles. - Loading States: Replace
isLoadingchecks with Suspense boundaries viacreatePage.