Server Routes Differences with PWA Kit
PWA Kit server routes are typically centralized as Express handlers in SSR server code. Storefront Next replaces that with file-based resource routes and loader/action handlers using standard Web Request/Response APIs. This distributes server behavior across route modules and aligns API endpoints with routing conventions.
| Aspect | PWA Kit | Storefront Next |
|---|---|---|
| Pattern | Express routes in ssr.js | File-based resource routes |
| Configuration | Centralized in one file | Distributed across route files |
| Request API | Express req/res objects | Web Standard Request/Response |
| Route Definition | app.get('/path', handler) | Export loader/action from file |
| Dynamic Routes | Express params (/:param) | File naming ($param) |
| Middleware | Express middleware chain | React Router middleware exports |
| Client Execution | Server only | Optional clientLoader/clientAction |
- Both support GET (loaders) and POST/PUT/DELETE (actions).
- Both can set cache headers and response status codes.
- Both integrate with SLAS for authentication callbacks.
- Both can proxy Commerce API calls.
- Both support dynamic route parameters.
Keep these tips in mind when you convert your PWA Kit storefront to Storefront Next.
- Route extraction: Move logic from
ssr.jscallbacks into separate route files. - Request handling: Convert Express
req.body/req.querytorequest.json()/URL.searchParams. - Response handling: Convert
res.json()toResponse.json(). - Middleware: Use React Router middleware exports instead of Express middleware.
- Client-side option: Consider adding
clientLoaderfor endpoints that can run on the client.