@shopify/hydrogen 2026.10.1 → 2026.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/README.md +3 -5
  2. package/dist/cli/index.mjs +8 -5
  3. package/dist/client/client.mjs +45 -12
  4. package/dist/client/client.mjs.map +1 -1
  5. package/dist/client/i18n-variables.d.mts +13 -0
  6. package/dist/client/i18n-variables.mjs +92 -0
  7. package/dist/client/i18n-variables.mjs.map +1 -0
  8. package/dist/client/types.d.mts +21 -8
  9. package/dist/core/cache/fetch-with-cache.mjs +8 -1
  10. package/dist/core/cache/fetch-with-cache.mjs.map +1 -1
  11. package/dist/core/cart/cart.mjs +111 -24
  12. package/dist/core/cart/cart.mjs.map +1 -1
  13. package/dist/core/cart/cookie.mjs +6 -1
  14. package/dist/core/cart/cookie.mjs.map +1 -1
  15. package/dist/core/cart/form.d.mts +17 -5
  16. package/dist/core/cart/form.mjs +5 -0
  17. package/dist/core/cart/form.mjs.map +1 -1
  18. package/dist/core/cart/index.d.mts +1 -1
  19. package/dist/core/cart/queries.d.mts +57 -57
  20. package/dist/core/collection/url.mjs +8 -1
  21. package/dist/core/collection/url.mjs.map +1 -1
  22. package/dist/core/constants.mjs +2 -1
  23. package/dist/core/constants.mjs.map +1 -1
  24. package/dist/core/csp/index.d.mts +56 -0
  25. package/dist/core/csp/index.mjs +117 -0
  26. package/dist/core/csp/index.mjs.map +1 -0
  27. package/dist/core/csp/types.d.mts +52 -0
  28. package/dist/core/headers.mjs +2 -2
  29. package/dist/core/headers.mjs.map +1 -1
  30. package/dist/core/i18n/define.d.mts +54 -0
  31. package/dist/core/i18n/define.mjs +135 -0
  32. package/dist/core/i18n/define.mjs.map +1 -0
  33. package/dist/core/i18n/errors.d.mts +18 -0
  34. package/dist/core/i18n/errors.mjs +24 -0
  35. package/dist/core/i18n/errors.mjs.map +1 -0
  36. package/dist/core/i18n/href.d.mts +28 -0
  37. package/dist/core/i18n/href.mjs +45 -0
  38. package/dist/core/i18n/href.mjs.map +1 -0
  39. package/dist/core/i18n/locale.d.mts +21 -0
  40. package/dist/core/i18n/locale.mjs +36 -0
  41. package/dist/core/i18n/locale.mjs.map +1 -0
  42. package/dist/core/i18n/match.d.mts +37 -0
  43. package/dist/core/i18n/match.mjs +82 -0
  44. package/dist/core/i18n/match.mjs.map +1 -0
  45. package/dist/core/i18n/types.d.mts +80 -0
  46. package/dist/core/index.d.mts +14 -5
  47. package/dist/core/index.mjs +9 -2
  48. package/dist/core/predictive-search/index.d.mts +2 -2
  49. package/dist/core/predictive-search/queries.d.mts +2 -2
  50. package/dist/core/predictive-search/server-handlers.d.mts +27 -6
  51. package/dist/core/predictive-search/server-handlers.mjs +1 -4
  52. package/dist/core/predictive-search/server-handlers.mjs.map +1 -1
  53. package/dist/core/predictive-search/url.d.mts +2 -2
  54. package/dist/core/predictive-search/url.mjs.map +1 -1
  55. package/dist/core/product/accept-variant-id.mjs +1 -1
  56. package/dist/core/product/accept-variant-id.mjs.map +1 -1
  57. package/dist/core/request-context.d.mts +61 -35
  58. package/dist/core/request-context.mjs +11 -7
  59. package/dist/core/request-context.mjs.map +1 -1
  60. package/dist/core/request-routing/handle-shopify-routes.mjs.map +1 -1
  61. package/dist/core/request-routing/interceptors/api-proxy.mjs +9 -1
  62. package/dist/core/request-routing/interceptors/api-proxy.mjs.map +1 -1
  63. package/dist/core/request-routing/interceptors/checkout.mjs +11 -5
  64. package/dist/core/request-routing/interceptors/checkout.mjs.map +1 -1
  65. package/dist/core/request-routing/interceptors/proxy.mjs.map +1 -1
  66. package/dist/core/request-routing/interceptors/standard-routes.mjs +1 -1
  67. package/dist/core/request-routing/interceptors/standard-routes.mjs.map +1 -1
  68. package/dist/core/request-routing/interceptors/url-redirects.mjs +2 -1
  69. package/dist/core/request-routing/interceptors/url-redirects.mjs.map +1 -1
  70. package/dist/core/request-routing/registered-routes.d.mts +13 -2
  71. package/dist/core/request-routing/registered-routes.mjs +33 -9
  72. package/dist/core/request-routing/registered-routes.mjs.map +1 -1
  73. package/dist/core/request-routing/route-types.d.mts +18 -8
  74. package/dist/core/shop-pay/shop-pay.mjs +5 -4
  75. package/dist/core/shop-pay/shop-pay.mjs.map +1 -1
  76. package/dist/core/shopify-scripts/analytics.mjs +3 -5
  77. package/dist/core/shopify-scripts/analytics.mjs.map +1 -1
  78. package/dist/core/shopify-scripts/constants.mjs +3 -1
  79. package/dist/core/shopify-scripts/constants.mjs.map +1 -1
  80. package/dist/core/shopify-scripts/global.mjs +13 -11
  81. package/dist/core/shopify-scripts/global.mjs.map +1 -1
  82. package/dist/core/shopify-scripts/hashes.d.mts +17 -0
  83. package/dist/core/shopify-scripts/hashes.mjs +12 -0
  84. package/dist/core/shopify-scripts/hashes.mjs.map +1 -0
  85. package/dist/core/shopify-scripts/index.d.mts +1 -0
  86. package/dist/core/shopify-scripts/index.mjs +12 -9
  87. package/dist/core/shopify-scripts/index.mjs.map +1 -1
  88. package/dist/core/shopify-scripts/page-view.mjs +4 -1
  89. package/dist/core/shopify-scripts/page-view.mjs.map +1 -1
  90. package/dist/core/shopify-scripts/perfkit.mjs +8 -2
  91. package/dist/core/shopify-scripts/perfkit.mjs.map +1 -1
  92. package/dist/core/shopify-scripts/types.d.mts +4 -2
  93. package/dist/core/shopify-scripts/utils/inline-script.mjs +4 -1
  94. package/dist/core/shopify-scripts/utils/inline-script.mjs.map +1 -1
  95. package/dist/core/standard-routes/build.d.mts +7 -2
  96. package/dist/core/standard-routes/build.mjs +10 -3
  97. package/dist/core/standard-routes/build.mjs.map +1 -1
  98. package/dist/core/standard-routes/match.mjs +11 -1
  99. package/dist/core/standard-routes/match.mjs.map +1 -1
  100. package/dist/core/standard-routes/path.mjs +14 -3
  101. package/dist/core/standard-routes/path.mjs.map +1 -1
  102. package/dist/core/standard-routes/types.d.mts +6 -1
  103. package/dist/core/url.mjs +5 -3
  104. package/dist/core/url.mjs.map +1 -1
  105. package/dist/core/utils/load-script.mjs +6 -6
  106. package/dist/core/utils/load-script.mjs.map +1 -1
  107. package/dist/customer-account/client.d.mts +14 -10
  108. package/dist/customer-account/client.mjs +4 -5
  109. package/dist/customer-account/client.mjs.map +1 -1
  110. package/dist/customer-account/graphql.d.mts +7 -1
  111. package/dist/customer-account/graphql.mjs +6 -7
  112. package/dist/customer-account/graphql.mjs.map +1 -1
  113. package/dist/customer-account/session.mjs +3 -4
  114. package/dist/customer-account/session.mjs.map +1 -1
  115. package/dist/development/client/client.mjs +45 -12
  116. package/dist/development/client/client.mjs.map +1 -1
  117. package/dist/development/client/i18n-variables.d.mts +13 -0
  118. package/dist/development/client/i18n-variables.mjs +92 -0
  119. package/dist/development/client/i18n-variables.mjs.map +1 -0
  120. package/dist/development/client/types.d.mts +21 -8
  121. package/dist/development/core/cache/fetch-with-cache.mjs +8 -1
  122. package/dist/development/core/cache/fetch-with-cache.mjs.map +1 -1
  123. package/dist/development/core/cart/cart.mjs +111 -24
  124. package/dist/development/core/cart/cart.mjs.map +1 -1
  125. package/dist/development/core/cart/cookie.mjs +6 -1
  126. package/dist/development/core/cart/cookie.mjs.map +1 -1
  127. package/dist/development/core/cart/form.d.mts +17 -5
  128. package/dist/development/core/cart/form.mjs +5 -0
  129. package/dist/development/core/cart/form.mjs.map +1 -1
  130. package/dist/development/core/cart/index.d.mts +1 -1
  131. package/dist/development/core/cart/queries.d.mts +57 -57
  132. package/dist/development/core/collection/url.mjs +8 -1
  133. package/dist/development/core/collection/url.mjs.map +1 -1
  134. package/dist/development/core/constants.mjs +2 -1
  135. package/dist/development/core/constants.mjs.map +1 -1
  136. package/dist/development/core/csp/index.d.mts +56 -0
  137. package/dist/development/core/csp/index.mjs +128 -0
  138. package/dist/development/core/csp/index.mjs.map +1 -0
  139. package/dist/development/core/csp/types.d.mts +52 -0
  140. package/dist/development/core/development.d.mts +14 -5
  141. package/dist/development/core/development.mjs +9 -2
  142. package/dist/development/core/headers.mjs +2 -2
  143. package/dist/development/core/headers.mjs.map +1 -1
  144. package/dist/development/core/i18n/define.d.mts +54 -0
  145. package/dist/development/core/i18n/define.mjs +135 -0
  146. package/dist/development/core/i18n/define.mjs.map +1 -0
  147. package/dist/development/core/i18n/errors.d.mts +18 -0
  148. package/dist/development/core/i18n/errors.mjs +24 -0
  149. package/dist/development/core/i18n/errors.mjs.map +1 -0
  150. package/dist/development/core/i18n/href.d.mts +28 -0
  151. package/dist/development/core/i18n/href.mjs +45 -0
  152. package/dist/development/core/i18n/href.mjs.map +1 -0
  153. package/dist/development/core/i18n/locale.d.mts +21 -0
  154. package/dist/development/core/i18n/locale.mjs +36 -0
  155. package/dist/development/core/i18n/locale.mjs.map +1 -0
  156. package/dist/development/core/i18n/match.d.mts +37 -0
  157. package/dist/development/core/i18n/match.mjs +82 -0
  158. package/dist/development/core/i18n/match.mjs.map +1 -0
  159. package/dist/development/core/i18n/types.d.mts +80 -0
  160. package/dist/development/core/index.d.mts +13 -4
  161. package/dist/development/core/predictive-search/index.d.mts +2 -2
  162. package/dist/development/core/predictive-search/queries.d.mts +2 -2
  163. package/dist/development/core/predictive-search/server-handlers.d.mts +27 -6
  164. package/dist/development/core/predictive-search/server-handlers.mjs +1 -4
  165. package/dist/development/core/predictive-search/server-handlers.mjs.map +1 -1
  166. package/dist/development/core/predictive-search/url.d.mts +2 -2
  167. package/dist/development/core/predictive-search/url.mjs.map +1 -1
  168. package/dist/development/core/product/accept-variant-id.mjs +1 -1
  169. package/dist/development/core/product/accept-variant-id.mjs.map +1 -1
  170. package/dist/development/core/request-context.d.mts +61 -35
  171. package/dist/development/core/request-context.mjs +11 -7
  172. package/dist/development/core/request-context.mjs.map +1 -1
  173. package/dist/development/core/request-routing/handle-shopify-routes.mjs.map +1 -1
  174. package/dist/development/core/request-routing/interceptors/api-proxy.mjs +9 -1
  175. package/dist/development/core/request-routing/interceptors/api-proxy.mjs.map +1 -1
  176. package/dist/development/core/request-routing/interceptors/checkout.mjs +11 -5
  177. package/dist/development/core/request-routing/interceptors/checkout.mjs.map +1 -1
  178. package/dist/development/core/request-routing/interceptors/proxy.mjs.map +1 -1
  179. package/dist/development/core/request-routing/interceptors/standard-routes.mjs +1 -1
  180. package/dist/development/core/request-routing/interceptors/standard-routes.mjs.map +1 -1
  181. package/dist/development/core/request-routing/interceptors/url-redirects.mjs +2 -1
  182. package/dist/development/core/request-routing/interceptors/url-redirects.mjs.map +1 -1
  183. package/dist/development/core/request-routing/registered-routes.d.mts +13 -2
  184. package/dist/development/core/request-routing/registered-routes.mjs +33 -9
  185. package/dist/development/core/request-routing/registered-routes.mjs.map +1 -1
  186. package/dist/development/core/request-routing/route-types.d.mts +18 -8
  187. package/dist/development/core/shop-pay/shop-pay.mjs +5 -4
  188. package/dist/development/core/shop-pay/shop-pay.mjs.map +1 -1
  189. package/dist/development/core/shopify-scripts/analytics.mjs +3 -5
  190. package/dist/development/core/shopify-scripts/analytics.mjs.map +1 -1
  191. package/dist/development/core/shopify-scripts/constants.mjs +3 -1
  192. package/dist/development/core/shopify-scripts/constants.mjs.map +1 -1
  193. package/dist/development/core/shopify-scripts/global.mjs +13 -11
  194. package/dist/development/core/shopify-scripts/global.mjs.map +1 -1
  195. package/dist/development/core/shopify-scripts/hashes.d.mts +17 -0
  196. package/dist/development/core/shopify-scripts/hashes.mjs +12 -0
  197. package/dist/development/core/shopify-scripts/hashes.mjs.map +1 -0
  198. package/dist/development/core/shopify-scripts/index.d.mts +1 -0
  199. package/dist/development/core/shopify-scripts/index.mjs +12 -9
  200. package/dist/development/core/shopify-scripts/index.mjs.map +1 -1
  201. package/dist/development/core/shopify-scripts/page-view.mjs +4 -1
  202. package/dist/development/core/shopify-scripts/page-view.mjs.map +1 -1
  203. package/dist/development/core/shopify-scripts/perfkit.mjs +8 -2
  204. package/dist/development/core/shopify-scripts/perfkit.mjs.map +1 -1
  205. package/dist/development/core/shopify-scripts/types.d.mts +4 -2
  206. package/dist/development/core/shopify-scripts/utils/inline-script.mjs +4 -1
  207. package/dist/development/core/shopify-scripts/utils/inline-script.mjs.map +1 -1
  208. package/dist/development/core/standard-routes/build.d.mts +7 -2
  209. package/dist/development/core/standard-routes/build.mjs +10 -3
  210. package/dist/development/core/standard-routes/build.mjs.map +1 -1
  211. package/dist/development/core/standard-routes/match.mjs +11 -1
  212. package/dist/development/core/standard-routes/match.mjs.map +1 -1
  213. package/dist/development/core/standard-routes/path.mjs +14 -3
  214. package/dist/development/core/standard-routes/path.mjs.map +1 -1
  215. package/dist/development/core/standard-routes/types.d.mts +6 -1
  216. package/dist/development/core/url.mjs +5 -3
  217. package/dist/development/core/url.mjs.map +1 -1
  218. package/dist/development/core/utils/load-script.mjs +6 -6
  219. package/dist/development/core/utils/load-script.mjs.map +1 -1
  220. package/dist/development/customer-account/session.mjs.map +1 -1
  221. package/dist/development/globals.d.mts +8 -4
  222. package/dist/development/graphql/type-resolver.d.mts +39 -1
  223. package/dist/development/react/cart.mjs +79 -25
  224. package/dist/development/react/cart.mjs.map +1 -1
  225. package/dist/development/react/index.d.mts +2 -2
  226. package/dist/globals.d.mts +8 -4
  227. package/dist/graphql/type-resolver.d.mts +39 -1
  228. package/dist/react/cart.mjs +79 -25
  229. package/dist/react/cart.mjs.map +1 -1
  230. package/dist/react/index.d.mts +2 -2
  231. package/dist/vite/index.d.mts +11 -1
  232. package/dist/vite/index.mjs +21 -1
  233. package/dist/vite/index.mjs.map +1 -0
  234. package/package.json +13 -3
  235. package/skills/hydrogen-analytics/SKILL.md +2 -2
  236. package/skills/hydrogen-analytics/references/react.md +2 -2
  237. package/skills/hydrogen-cart-ui/SKILL.md +2 -2
  238. package/skills/hydrogen-markets/SKILL.md +127 -93
  239. package/skills/hydrogen-markets/references/nextjs.md +77 -87
  240. package/skills/hydrogen-oxygen/references/react-router.md +1 -2
  241. package/skills/hydrogen-predictive-search/SKILL.md +18 -1
  242. package/skills/hydrogen-request-handlers/SKILL.md +24 -6
  243. package/skills/hydrogen-request-handlers/references/content-security-policy.md +103 -0
  244. package/skills/hydrogen-request-handlers/references/frameworks.md +9 -12
  245. package/skills/hydrogen-request-handlers/references/nextjs.md +7 -3
  246. package/skills/hydrogen-request-handlers/references/nuxt.md +7 -7
  247. package/skills/hydrogen-robots-txt/SKILL.md +87 -0
  248. package/skills/hydrogen-routing/SKILL.md +36 -14
  249. package/skills/hydrogen-setup/SKILL.md +2 -2
  250. package/skills/hydrogen-setup/references/analytics.md +5 -5
  251. package/skills/hydrogen-setup/steps/2-scaffold.md +3 -0
  252. package/skills/hydrogen-setup/steps/7-shopify-runtime-scripts.md +4 -3
  253. package/skills/hydrogen-setup/steps/9-account-page.md +1 -1
  254. package/skills/hydrogen-smoke-test/SKILL.md +9 -2
  255. package/skills/hydrogen-storefront-client/SKILL.md +29 -9
  256. package/skills/hydrogen-storefront-client/references/astro.md +8 -3
  257. package/skills/hydrogen-storefront-client/references/caching.md +2 -0
  258. package/skills/hydrogen-storefront-client/references/nextjs.md +8 -3
  259. package/skills/hydrogen-storefront-client/references/nuxt.md +9 -5
  260. package/skills/hydrogen-storefront-client/references/react-router.md +6 -3
  261. package/skills/hydrogen-storefront-client/references/solidstart.md +6 -2
  262. package/skills/hydrogen-storefront-client/references/sveltekit.md +10 -4
  263. package/skills/migrate-to-hydrogen-2026-10/SKILL.md +20 -22
  264. package/skills/migrate-to-hydrogen-2026-10/references/sitemap-and-seo.md +1 -0
  265. package/skills/migrate-to-hydrogen-2026-10/references/typescript-and-gql-tada.md +1 -1
@@ -15,7 +15,7 @@ Migrate a classic-Hydrogen storefront (Remix- or React-Router-based) to Hydrogen
15
15
 
16
16
  ## The mental model (get this right first)
17
17
 
18
- 1. **Hydrogen 2026-10 is a server-handler library, not a framework.** (A `@shopify/hydrogen` version **before `2026.10` is still the old framework**, not the library — the classic line runs through `2026.4.x` — so an installed version below `2026.10` means the store hasn't been migrated yet, regardless of its React Router status.) You compose the request lifecycle yourself: `createShopifyRequestContext({request, i18n, buyerIp})` → `createStorefrontClient({type: 'private', requestContext, config})` (config carries `storeDomain`, `privateStorefrontToken`, `storefrontId`, `cache`, `waitUntil`; a store without a private token uses `type: 'public'` instead — see the `hydrogen-storefront-client` packaged skill for the choice) → `handleShopifyRoutes({request, requestContext, sessionManager, storefrontClient, routeTemplates, handlers})` (returns a `Promise<Response>` for handler-owned paths, else `null` — decided synchronously, so truthy-check it without `await`) → `handleShopifyRedirects` on 404 → handler groups for the rest: `createCartServerHandlers()` for cart and `createCustomerAccountServerHandlers(…)` (from `@shopify/hydrogen/customer-account`) for auth, both registered through the `handlers` array. Hydrogen no longer owns routing or the entry — you wire these into your React Router server/middleware.
18
+ 1. **Hydrogen 2026-10 is a server-handler library, not a framework.** (A `@shopify/hydrogen` version **before `2026.10` is still the old framework**, not the library — the classic line runs through `2026.4.x` — so an installed version below `2026.10` means the store hasn't been migrated yet, regardless of its React Router status.) You compose the request lifecycle yourself: `createShopifyRequestContext({request, i18n, buyerIp})` → `createStorefrontClient({type: 'private', requestContext, config})` (config carries `storeDomain`, `privateStorefrontToken`, `storefrontId`, `cache`, `waitUntil`; a store without a private token uses `type: 'public'` instead — see the `hydrogen-storefront-client` packaged skill for the choice) → `handleShopifyRoutes({request, requestContext, storefrontClient, routeTemplates, handlers})`, plus `sessionManager` when a registered handler reads the session (returns a `Promise<Response>` for handler-owned paths, else `null` — decided synchronously, so truthy-check it without `await`) → `handleShopifyRedirects` on 404 → handler groups for the rest: `createCartServerHandlers()` for cart and `createCustomerAccountServerHandlers(…)` (from `@shopify/hydrogen/customer-account`) for auth, both registered through the `handlers` array. Hydrogen no longer owns routing or the entry — you wire these into your React Router server/middleware.
19
19
 
20
20
  2. **Dev and build are plain Vite/React Router — the classic `shopify hydrogen dev|build` commands and the `hydrogen()` Vite plugin are gone.** `dev` is `vite dev` with the `oxygen()` plugin from `@shopify/mini-oxygen/vite` (workerd runtime, `.env` injection); `build` is `react-router build`; `preview` is `vite preview` after a build. The `hydrogen` bin that ships with the library covers the rest: `hydrogen setup`, `hydrogen skills check|sync`, `hydrogen gql check`, `npx hydrogen certs install|uninstall` for local HTTPS. `@shopify/cli` stays a devDependency for the `shopify hydrogen` commands the library does not replace: `deploy`, `link`, `env pull`. Do **not** add `@shopify/hydrogen-classic` or any aliased classic package — the 2026-10 library has no classic sibling.
21
21
 
@@ -33,19 +33,20 @@ Hydrogen migration:
33
33
  - [ ] 1. Dependencies + version pins (@shopify/hydrogen ^2026.10.0 and the seed below; drop classic-era deps)
34
34
  - [ ] 2. Scripts: hydrogen skills check --mode=warn && vite dev / react-router build / vite preview; deploy via @shopify/cli
35
35
  - [ ] 3. vite.config plugins: [localHttps({enabled}), ...oxygen(), reactRouter()]
36
- - [ ] 4. react-router.config.ts added (v8_middleware on, buildDirectory 'dist')
37
- - [ ] 5. Request wiring (request context + storefront client + route templates + session manager)
36
+ - [ ] 4. react-router.config.ts added (middleware enabled for your React Router version, buildDirectory 'dist')
37
+ - [ ] 5. Request wiring (request context + storefront client + route templates, plus a session manager when a handler needs one)
38
38
  - [ ] 6. Route filename + import + json()/defer() sweep
39
- - [ ] CSP/nonce: classic's utilities are gone — port CSP/nonce as app code, then check the browser console for CSP violations
39
+ - [ ] CSP/nonce: create a per-document policy with `createContentSecurityPolicy({shop})` and apply it with `csp.applyResponseHeaders(response.headers)`; keep React nonce context in app code, then check the browser console for CSP violations
40
40
  - [ ] 7. Connect a store — env vars in .env (private token, or public token), or MOCK_SHOP=1 for the tokenless mock.shop demo
41
41
  - [ ] Optional subsystems: detect each → migrate or skip, and report every skip
42
+ - [ ] Root middleware runs: GET /api/cart returns 200 JSON from the cart handler; a 404 or the app's 404 page means middleware isn't enabled for your React Router version (step 4)
42
43
  - [ ] 8. Verify (build/typecheck gate, hydrogen-smoke-test, browser console on the home page), then hand off to the user
43
44
  ```
44
45
 
45
46
  1. **Dependencies** — *(Remix swap only if not already on React Router)* replace `@remix-run/react`, `@remix-run/node`, `@remix-run/server-runtime`, `@remix-run/dev` and `@shopify/remix-oxygen` with `react-router` + `@react-router/dev` (pin all React Router packages to one version; `react-router-dom` is not needed). Add `@shopify/hydrogen`, `@shopify/mini-oxygen`, `vite`, the `@types/*` packages and `@shopify/cli` at the versions in the seed below. Remove `@shopify/cli-hydrogen` and any `@shopify/hydrogen-classic`-style alias if present. Align versions to the seed rather than picking latest of each independently, and never pin React Router below the version the app already runs.
46
47
  2. **Scripts** — `dev`: `hydrogen skills check --mode=warn && vite dev` (the prefix prints the resync command after a later `@shopify/hydrogen` bump without blocking dev; plain `hydrogen skills check` belongs in CI); `build`: `react-router build`; `preview`: `react-router build && vite preview`; `deploy`: `shopify hydrogen deploy --assets-dir dist/client --worker-dir dist/server`. Add `dev:https` with the **same** command — the vite.config computes the `localHttps` `enabled` flag from `npm_lifecycle_event` (step 3), not the script body.
47
48
  3. **`vite.config`** — plugins are `[localHttps({enabled}), ...oxygen(), reactRouter()]`, with `localHttps` from `@shopify/hydrogen/vite` and `oxygen` from `@shopify/mini-oxygen/vite` (it returns an **array** — spread it). `localHttps` takes a **required** `enabled: boolean` — it does not self-detect; compute it in the config: `const enabled = process.env.npm_lifecycle_event === 'dev:https'`. There is no `hydrogen()` plugin anymore. You do **not** pass an oxygen `entry` — it picks up the React Router server build.
48
- 4. **`react-router.config.ts`** — add it (React Router framework config + future flags; `v8_middleware: true` is required for the middleware skeleton below). Set `buildDirectory: 'dist'` — React Router defaults to `build/`, and the deploy script's `--assets-dir dist/client --worker-dir dist/server` flags silently point at nothing without it. Explicit `routes.ts` route config and flat routes via `@react-router/fs-routes` both work — for a migration, fs-routes preserves the existing flat route filenames with the least churn.
49
+ 4. **`react-router.config.ts`** — add it (React Router framework config + future flags). Make sure middleware is enabled for your version of React Router — the middleware skeleton below depends on it. Set `buildDirectory: 'dist'` — React Router defaults to `build/`, and the deploy script's `--assets-dir dist/client --worker-dir dist/server` flags silently point at nothing without it. Explicit `routes.ts` route config and flat routes via `@react-router/fs-routes` both work — for a migration, fs-routes preserves the existing flat route filenames with the least churn.
49
50
  5. **Request wiring** — in your server entry or a root middleware, build the request context and clients (mental-model step 1) and expose the storefront client to loaders via typed React Router contexts. If you already thread Oxygen `env`/`executionContext` through a context provider, keep it — the library does not force a specific context shape.
50
51
  6. **Routes & imports** — *(skip the import swap if already on React Router)* swap `@remix-run/*` imports to `react-router`; migrate `json()`/`defer()` loader/action return helpers.
51
52
  7. **Connect a store** — set `PUBLIC_STORE_DOMAIN`, `PUBLIC_STOREFRONT_ID` and `PRIVATE_STOREFRONT_API_TOKEN` in `.env` (on Oxygen, a linked storefront injects them); a store with only `PUBLIC_STOREFRONT_API_TOKEN` still uses the real store through the public client. Customer accounts add `SHOP_ID`, `PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID` and `SESSION_SECRET` (full list in `references/dependencies-and-tooling.md`). With `MOCK_SHOP=1`, or no store domain at all, the skeleton's client factory falls back to the tokenless mock.shop demo store — useful to verify the migration before the user supplies credentials. mock.shop only accepts a **tokenless public client** (it rejects the private-token header with a 401), and it is a catalog of fictional stores: https://mock.shop/llms.txt lists them.
@@ -144,6 +145,7 @@ import {
144
145
  type CachingStrategy,
145
146
  createShopifyRequestContext,
146
147
  createStorefrontClient,
148
+ defineShopifyI18n,
147
149
  type PublicStorefrontClient,
148
150
  type RequestScopedPrivateStorefrontClient,
149
151
  type ShopifyRequestContext,
@@ -173,14 +175,15 @@ function getBuyerIp(headers: Headers) {
173
175
  throw new Error('No buyer IP header on the request');
174
176
  }
175
177
 
178
+ // Module scope. Add `routing` to serve more locales by path prefix or hostname; the request context matches the locale from the URL.
179
+ const i18n = defineShopifyI18n({defaultLocale: {country: 'US', language: 'EN'}});
180
+
176
181
  export function createRequestStorefrontClient(
177
182
  request: Request,
178
183
  env: Env,
179
184
  cache: CacheInstance,
180
185
  waitUntil: ExecutionContext['waitUntil'],
181
186
  ): RequestStorefrontClient {
182
- const i18n = {country: 'US', language: 'EN'} as const; // or derive from the URL/domain
183
-
184
187
  // mock.shop is auth-free and 401s any token header, so it always gets the tokenless public client.
185
188
  if (env.MOCK_SHOP === '1' || !env.PUBLIC_STORE_DOMAIN) {
186
189
  return createStorefrontClient({
@@ -223,21 +226,20 @@ export function createRequestStorefrontClient(
223
226
  `app/lib/route-templates.ts` — maps Shopify entities to your route shapes. Pass it to `handleShopifyRoutes` (optional in the type, but handler-owned URLs come out wrong without it), to `handleShopifyRedirects` (**required** there), and to the `routes` prop of `ShopifyScripts`:
224
227
 
225
228
  ```ts
226
- import {createShopifyRouteTemplates} from '@shopify/hydrogen';
227
- export const routeTemplates = createShopifyRouteTemplates({
229
+ import {defineShopifyRouteTemplates} from '@shopify/hydrogen';
230
+ export const routeTemplates = defineShopifyRouteTemplates({
228
231
  productInCollection: '/products/:productHandle',
229
232
  });
230
233
  ```
231
234
 
232
- **Classic data-layer call-sites map mechanically:** `storefront.query()` → `client.graphql(QUERY, {variables, cache})`, which returns `{data, errors, headers}` instead of merging errors into the result — check `errors` before reading `data`; `$country`/`$language` are auto-injected, so drop them from `variables`; `storefront.CacheLong()` → the per-call `Cache.long()` (classic's implicit default caching is **gone**, so give every query that relied on it an explicit `cache`, `Cache.short()` or `Cache.long()`, or it hits the API on every request); `storefront.i18n` → `client.i18n`.
235
+ **Classic data-layer call-sites map mechanically:** `storefront.query()` → `client.graphql(QUERY, {variables, cache})`, which returns `{data, errors, headers}` instead of merging errors into the result — check `errors` before reading `data`; `$country`/`$language` are auto-injected, so drop them from `variables`; `storefront.CacheLong()` → the per-call `Cache.long()` (classic's implicit default caching is **gone**, so give every query that relied on it an explicit `cache`, `Cache.short()` or `Cache.long()`, or it hits the API on every request); `storefront.i18n` → `client.locale` (the resolved `{language, country, pathPrefix}`; `client.i18n` is a deprecated alias of it).
233
236
 
234
- Root **middleware** in `app/root.tsx` (needs `future.v8_middleware`) — the request lifecycle from mental-model step 1:
237
+ Root **middleware** in `app/root.tsx` (needs middleware enabled, see step 4) — the request lifecycle from mental-model step 1:
235
238
 
236
239
  ```ts
237
240
  import {handleShopifyRedirects, handleShopifyRoutes} from '@shopify/hydrogen';
238
241
  import {cartHandlers} from '~/lib/cart-handlers';
239
242
  import {routeTemplates} from '~/lib/route-templates';
240
- import {createEphemeralSessionManager} from '~/lib/session';
241
243
  import {
242
244
  createRequestStorefrontClient, envContext, storefrontClientContext, storefrontRequestContext,
243
245
  } from '~/lib/storefront';
@@ -248,10 +250,9 @@ export const middleware: Route.MiddlewareFunction[] = [
248
250
  const env = context.get(envContext);
249
251
  const storefrontClient = createRequestStorefrontClient(request, env, context.cache, context.waitUntil);
250
252
  const requestContext = storefrontClient.requestContext; // reuse — a fresh one throws in handleShopifyRoutes
251
- const sessionManager = createEphemeralSessionManager(request);
252
253
 
253
254
  const shopifyRoute = handleShopifyRoutes({ // handler-owned paths (e.g. /api/cart) return early
254
- request, requestContext, sessionManager, storefrontClient, routeTemplates, handlers: [cartHandlers],
255
+ request, requestContext, storefrontClient, routeTemplates, handlers: [cartHandlers], // cart handlers don't read the session
255
256
  });
256
257
  if (shopifyRoute) return shopifyRoute; // Promise<Response> or null — do NOT await the call
257
258
 
@@ -259,9 +260,6 @@ export const middleware: Route.MiddlewareFunction[] = [
259
260
  context.set(storefrontRequestContext, requestContext);
260
261
 
261
262
  const response = await next();
262
-
263
- const sessionHeaders = new Headers((await sessionManager.commit?.()) ?? undefined);
264
- for (const [name, value] of sessionHeaders) response.headers.append(name, value);
265
263
  if (response.status === 404) { // 404 → Shopify URL redirects
266
264
  const redirect = await handleShopifyRedirects({request, storefrontClient, routeTemplates});
267
265
  if (redirect) return redirect; // headers already applied by the library
@@ -272,7 +270,7 @@ export const middleware: Route.MiddlewareFunction[] = [
272
270
  ];
273
271
  ```
274
272
 
275
- `app/lib/session.ts` — the `sessionManager` contract is **four required methods** (item values are typed `unknown`, not `string`) plus an optional `commit()` that returns cookie headers, which the middleware above applies. A per-request in-memory map satisfies the contract and is enough for carts, but it **cannot complete Customer Account login**: the OAuth state is written on `/account/login` and read back on `/account/authorize`, two different requests. For customer accounts, copy the template's cookie-backed `createRequestSessionManager` (a signed `__Host-session` cookie built on `@remix-run/cookie` + `@remix-run/session`, keyed by `SESSION_SECRET`):
273
+ **Session manager — only when a handler reads the session.** Plain `createCartServerHandlers()` doesn't, so the cart-only middleware above passes no `sessionManager`. Customer Account handlers and cart handlers created with `customerSession` do, and `handleShopifyRoutes` then requires one at the type level. The `sessionManager` contract is **four required methods** (item values are typed `unknown`, not `string`) plus an optional `commit()` that returns cookie headers; after `next()`, append those headers to the response before the 404 check, as the template's root middleware does. For customer accounts, copy the template's cookie-backed `createRequestSessionManager` from `app/lib/session.ts` (a signed `__Host-session` cookie built on `@remix-run/cookie` + `@remix-run/session`, keyed by `SESSION_SECRET`). An in-memory map can't complete Customer Account login: the OAuth state is written on `/account/login` and read back on `/account/authorize`, two different requests. If you register the account handlers only when Customer Accounts are configured, as the template does, the handler types still require a session manager on every request. For requests without Customer Accounts, the template passes an in-memory stand-in:
276
274
 
277
275
  ```ts
278
276
  import type {WritableCustomerSessionManager} from '@shopify/hydrogen/customer-account';
@@ -293,9 +291,9 @@ export function createEphemeralSessionManager(request: Request): WritableCustome
293
291
  }
294
292
  ```
295
293
 
296
- Supporting files: `app/lib/cart-handlers.ts` → `export const cartHandlers = createCartServerHandlers()` (options: `fragment` to extend the cart query, `customerSession` to sync buyer identity — see `references/cart.md`); `app/lib/cart.ts` → `createCartComponents<typeof cartHandlers>()` yields `CartProvider`/`useCart`/`useCartForm`; when the store has customer accounts, add the `createCustomerAccountServerHandlers({customerSession, …})` group next to `cartHandlers` in the middleware's `handlers` array and swap the session manager for the cookie-backed one (see `references/customer-account.md`); `react-router.config.ts` → `{buildDirectory: 'dist', future: {v8_middleware: true}}`.
294
+ Supporting files: `app/lib/cart-handlers.ts` → `export const cartHandlers = createCartServerHandlers()` (options: `fragment` to extend the cart query, `customerSession` to sync buyer identity — see `references/cart.md`); `app/lib/cart.ts` → `createCartComponents<typeof cartHandlers>()` yields `CartProvider`/`useCart`/`useCartForm`; when the store has customer accounts, add the `createCustomerAccountServerHandlers({customerSession, …})` group next to `cartHandlers` in the middleware's `handlers` array and pass the cookie-backed session manager as `sessionManager` (see `references/customer-account.md`); `react-router.config.ts` → `{buildDirectory: 'dist'}` plus middleware enabled for your version of React Router (step 4).
297
295
 
298
- Two lines in that middleware are easy to omit and fail **silently**: `applyResponseHeaders` on the normal response path (Shopify response headers disappear) and `routeTemplates` into both handler calls (handler-owned URLs and redirect targets come out wrong). A third, `buyerIp` into `createShopifyRequestContext`, fails **loudly** for the private client (`TypeError: requestContext.buyerIp is required for private Storefront API clients`) — keep the `getBuyerIp` helper rather than deleting the option to silence it. For the customer-account session wiring, follow the `hydrogen-customer-account` packaged skill rather than extending the in-memory manager by hand.
296
+ Two lines in that middleware are easy to omit and fail **silently**: `applyResponseHeaders` on the normal response path (Shopify response headers disappear) and `routeTemplates` into both handler calls (handler-owned URLs and redirect targets come out wrong). A third, `buyerIp` into `createShopifyRequestContext`, fails **loudly** for the private client (`TypeError: requestContext.buyerIp is required for private Storefront API clients`) — keep the `getBuyerIp` helper rather than deleting the option to silence it. For the customer-account session wiring, follow the `hydrogen-customer-account` packaged skill rather than extending the in-memory stand-in by hand.
299
297
 
300
298
  ## Optional subsystems
301
299
 
@@ -321,11 +319,11 @@ Each file is a short list of the specific "it renders but is wrong" traps for th
321
319
 
322
320
  ## Verification
323
321
 
324
- Don't trust "it renders." Gate on the build first: `react-router build` and `react-router typegen && tsc && hydrogen gql check --fail-on-warn` must both exit 0 (most import/return-helper and gql traps surface here — fix the root cause, don't suppress it; a red build makes everything downstream meaningless). Then run the local `hydrogen-smoke-test` skill for functional/runtime verification — request handlers, product, cart, collection/search, analytics, money, and the production pass. That skill owns "does the storefront work"; don't restate its checks here.
322
+ Don't trust "it renders." Gate on the build first: `react-router build` and `react-router typegen && tsc && hydrogen gql check --fail-on-warn` must both exit 0 (most import/return-helper and gql traps surface here — fix the root cause, don't suppress it; a red build makes everything downstream meaningless). Next, prove the root middleware actually runs: with the dev server up, `GET /api/cart` must return 200 JSON from the Hydrogen cart handler. A 404, or the app's own 404 page, means middleware isn't enabled for your React Router version (step 4), so cart routes, redirects, the storefront context and response headers are all silently skipped. Then run the local `hydrogen-smoke-test` skill for functional/runtime verification — request handlers, product, cart, collection/search, analytics, money, and the production pass. That skill owns "does the storefront work"; don't restate its checks here.
325
323
 
326
324
  After the build gate and smoke test pass, **keep the dev server running and load the home page in a browser.** Fix every console error and warning before handing off. If you have no browser tool, say so in the handoff and ask the user to check the console themselves. Then hand off to the user. Tell them to test the migrated code with `npm run dev` (or `npm run dev:https` when they need customer login locally), and to pay special attention to the areas a migration most often gets subtly wrong while still compiling:
327
325
 
328
- - **CSP/nonce** — classic Hydrogen's `createContentSecurityPolicy`/`NonceProvider`/`useNonce` are gone; CSP is app-owned now, so port it as your own app code. A dropped nonce leaves pages rendering fine while hydration (cart, variant picker, analytics) is silently dead — check the browser console for CSP violations after migrating.
326
+ - **CSP/nonce** — use `createContentSecurityPolicy({shop})` from `@shopify/hydrogen`. The returned policy exposes `nonce` and `header`; `csp.applyResponseHeaders()` sends the policy and prevents nonce-bearing HTML from being cached. Apply Shopify request-context headers separately with `requestContext.applyResponseHeaders(response.headers)`. Keep `NonceProvider`/`useNonce` in app code and pass the nonce to the server renderer, framework scripts, and `ShopifyScripts`. For cached HTML or a prerendered shell, use `nonce: false` and authorize inline scripts explicitly; CSP then leaves cache headers unchanged. Move classic's top-level directive properties under `directives`; arrays still extend defaults, with a replacement exception for defaults consisting only of `'none'`. Convert source strings to arrays and `false` omissions to `null`. Review `defaultSrc` customizations: the new policy has explicit script, image, font, media, and frame directives that take precedence over the fallback. The development build adds common local connection sources automatically. See `hydrogen-request-handlers/references/content-security-policy.md` for the full migration comparison and framework wiring. A dropped nonce can silently prevent hydration — verify browser behavior after migrating.
329
327
  - **Analytics** — the commerce funnel (`view_item`/`add_to_cart`/…) silently dropping while page views still fire (`references/analytics.md`).
330
328
  - **Cart actions** — add / remove / quantity edits and the drawer opening on add (`references/cart.md`).
331
329
  - **Customer login** — the full OAuth round-trip, which needs an HTTPS origin locally (`references/customer-account.md`).
@@ -3,3 +3,4 @@
3
3
  Read if the source has `sitemap.xml`/`robots.txt` routes or a `seo` export.
4
4
 
5
5
  - **Sitemaps: `getSitemap`/`getSitemapIndex` are gone.** The 2026-10 library does not ship them, and the classic versions were typed for the classic `Storefront` client (`.query`) — the new request-scoped client only exposes `.graphql`, so they don't port. Write a small local `app/lib/sitemap.ts` that runs the sitemap queries via `storefront.graphql` and preserves any custom URL transforms (renamed routes, locale prefixes). The route files then call the local lib.
6
+ - **robots.txt: keep the merchant's rules, then add the new handler paths.** The classic route ports as-is, so don't swap it for a default file. Remove anything that queries the classic client (`context.storefront.query(ROBOTS_QUERY)` for `shop.id`, used only to build `/{shopId}/checkouts` and `/{shopId}/orders` rules). Re-check each rule against the migrated routes, and drop rules for paths the app no longer serves. Then add rules for the paths Hydrogen 2026-10's request handlers serve when they aren't already covered: `/admin`, `/checkout`, `/buy/`, `/api/`, `/__shopify`. Keep `/.well-known/` reachable. Invoke the `hydrogen-robots-txt` skill for the reason behind each rule. If the source has no robots.txt route, add one with that skill.
@@ -3,5 +3,5 @@
3
3
  These surface when you run `react-router typegen && tsc` and `hydrogen gql check`. Read before wiring typed queries or re-pointing imports.
4
4
 
5
5
  - **Typed GraphQL runs through the library's ts-plugin, not app-owned gql.tada config.** `@shopify/hydrogen` ships the schemas and a TypeScript plugin: add `{"name": "@shopify/hydrogen/ts-plugin"}` to `compilerOptions.plugins` in `tsconfig.json` and delete any classic-era gql.tada `schema`/`schemas` tsconfig block pointing at generated schema files. The plugin writes its schema environments (`*-graphql-env.d.ts`) at the **project root**; gitignore them. Add `hydrogen gql check --fail-on-warn` to the `typecheck` script — a wrong setup fails silently otherwise: typing just stops working, and nothing errors until you run the check. Type results with the `StorefrontApi` namespace / `ResultOf`; the library's `gql()` returns a **branded query string**, not a gql.tada document, so `FragmentOf` does **not** apply — to type a fragment's data, compose a throwaway query that spreads the fragment and take `ResultOf` of that (see the `hydrogen-storefront-client` packaged skill).
6
- - **Framework types dropped from core are gone — but check the installed exports before shimming.** Types the app imported from `@shopify/hydrogen` in classic Hydrogen (e.g. `I18nBase`) may no longer be exported, so a bare type import fails with "no exported member". `I18nBase` → the library's `I18nConfig`. API object types → `@shopify/hydrogen/storefront-api-types` and `.../customer-account-api-types`. Several classic helpers **returned to core** (`flattenConnection`, `getSelectedProductOptions`, `formatMoney`, the `MoneyV2` type) — grep the installed package's `.d.mts` exports first. Only what is genuinely absent (component prop shapes, other helpers' types) gets a small local structural type for the fields the app actually uses; there is no classic package to fall back to.
6
+ - **Framework types dropped from core are gone — but check the installed exports before shimming.** Types the app imported from `@shopify/hydrogen` in classic Hydrogen (e.g. `I18nBase`) may no longer be exported, so a bare type import fails with "no exported member". `I18nBase` → the library's `ShopifyLocale` (or `ShopifyMatchedLocale` for the resolved locale with `pathPrefix`). API object types → `@shopify/hydrogen/storefront-api-types` and `.../customer-account-api-types`. Several classic helpers **returned to core** (`flattenConnection`, `getSelectedProductOptions`, `formatMoney`, the `MoneyV2` type) — grep the installed package's `.d.mts` exports first. Only what is genuinely absent (component prop shapes, other helpers' types) gets a small local structural type for the fields the app actually uses; there is no classic package to fall back to.
7
7
  - **gql result types are *partial and union-shaped*, unlike the old generated types.** Two distinct traps: (1) A query on a union/interface field (storefront `search`, metaobject `references`) is typed as the **full union** — the `types:`/`unavailableProducts:` argument and a single `...on X` inline fragment do **not** narrow it at the type level, so non-`X` members appear with only `__typename` and field access fails. Narrow with `Extract<…nodes[number], {__typename: 'X'}>` (a cast is honest here since the arg guarantees the runtime type). (2) A selection-derived type is **not** assignable to the full `storefront-api-types` type a component prop declares (e.g. `ProductVariant` requires `metafields` via `HasMetafields`, which the query didn't select). Either loosen the prop to the fields actually read (structural type) or bridge with a cast at the one boundary. Make `<Money>`/price components accept a structural `{amount, currencyCode}` and tolerate `null`/`undefined` — this also resolves the storefront-vs-customer-account `MoneyV2` **brand clash** that otherwise fails at every account money render.