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.

AspectPWA KitStorefront Next
PatternExpress routes in ssr.jsFile-based resource routes
ConfigurationCentralized in one fileDistributed across route files
Request APIExpress req/res objectsWeb Standard Request/Response
Route Definitionapp.get('/path', handler)Export loader/action from file
Dynamic RoutesExpress params (/:param)File naming ($param)
MiddlewareExpress middleware chainReact Router middleware exports
Client ExecutionServer onlyOptional 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.js callbacks into separate route files.
  • Request handling: Convert Express req.body/req.query to request.json()/URL.searchParams.
  • Response handling: Convert res.json() to Response.json().
  • Middleware: Use React Router middleware exports instead of Express middleware.
  • Client-side option: Consider adding clientLoader for endpoints that can run on the client.