@asteby/storefront-kit
v0.1.1
Published
React Router v7 adapter for @asteby/storefront stores: per-destination session cookies, SWR cache, Node server runtime and route modules, behind subpaths. Skeleton: the subpaths are typed and documented; the implementations land in follow-up changes.
Downloads
425
Readme
@asteby/storefront-kit
React Router v7 adapter for stores built on @asteby/storefront (pure client and rules) and
@asteby/storefront-react (UI). It is where the "glue" every store used to copy lives: session
cookies, cache, the Node server runtime and the route modules.
Status: skeleton. Every subpath below is typed and documented but still empty of behaviour. The implementations arrive one subpath at a time, each as an additive minor. Do not move store code here by hand; each piece is extracted with a parity test against the stores that carry it today.
Why a separate package
@asteby/storefront-react does not depend on a router (it takes renderLink and plain actions). react-router and
the Node HTTP runtime therefore live here, as peers, so a store that does not use them never installs them.
Install
pnpm add @asteby/storefront @asteby/storefront-react @asteby/storefront-kit react-routerPeers: react-router ^7, @asteby/storefront >=0.55 <1 (a fixed range on purpose: ^0.x would freeze the minor; widen it when the SDK goes 1.0). @asteby/storefront-react and react become peers in the change that adds the first subpath importing them; until then nothing in the kit imports them.
Subpaths
| Import | Runs in | What it will hold |
| --- | --- | --- |
| @asteby/storefront-kit/session | Node, edge | createStoreSession: signed cookies per slot (cart, customer, receipt, pay, selection), optional per-destination scoping and legacy cookie names. |
| @asteby/storefront-kit/cache | Node, edge | SWR cache for Ops reads, cacheHeaders(kind), per-request memo. |
| @asteby/storefront-kit/server | Node only | createStoreServer: the HTTP runtime with built-in plugins (compress, security-headers, image-variants, storage-proxy, resilience, demo-gate) and the store's own StorePlugins. |
| @asteby/storefront-kit/routes | Node, edge, build | Route-module factories (cart, checkout pay/status, returns, newsletter, sitemap/robots/llms) and the generated route table. |
| @asteby/storefront-kit/css | Tailwind | One stylesheet that adds the @source lines for the installed SDK packages. |
/* app/app.css */
@import '@asteby/storefront-kit/css';Extension contract (seams)
A store is a thin layer on top of the kit. Its own code may live only in the declared seams; outside them there is no store-owned file, so an upgrade never has to merge anything.
| Seam | Typical location | Holds |
| --- | --- | --- |
| components | app/store/** | Own sections and components. |
| config | app/config/** | Store configuration. |
| i18n | app/i18n/overrides | Text overrides per locale. |
| theme | app/theme/** | Theme tokens. |
| mocks | app/mocks/** | Mock data for the mock mode. |
The store declares them in store.extensions.json, and the drift check reads its layers from that file instead of
hard-wired patterns:
{
"version": 1,
"seams": {
"components": ["app/store/**"],
"config": ["app/config/**"],
"i18n": ["app/i18n/overrides/**"],
"theme": ["app/theme/**"],
"mocks": ["app/mocks/**"]
}
}(StoreExtensionsManifest in @asteby/storefront-kit/routes types this file.)
On top of the file seams, each route module exposes the same three overrides (RouteModuleOverrides), which is the
only way to change a kit route:
// Planned shape; the factories land with the route modules.
checkoutPayRoute({
hidden: ['cash'], // hide parts of the module by id
slots: { aside: <MyNotice /> }, // named content slots the module renders at fixed points
messages: { 'pay.title': '…' }, // message overrides, by id
})Rules of the contract:
- Nothing hardcoded. Cookie names, lifetimes, cache sizes, plugin lists, route prefixes and texts are options that the store takes from its Ops profile or its config, never constants inside the kit.
- General. No store, market or industry names appear in the kit. Industry differences are configuration that turns on general pieces.
- Additive. New options are optional and off by default; existing exports are not removed in a minor.
- Repeated three times, extracted. A file that two stores both carry outside the seams is a candidate to move into the kit; three block the build.
- Destination, not market. Per-destination scoping uses the destination of
@asteby/storefront. "Branch" in a store means a pickup point and is never used for the destination.
Development
pnpm --filter @asteby/storefront-kit build
pnpm --filter @asteby/storefront-kit testsrc/size-budget.test.ts bundles each subpath with the peers external and fails if a subpath grows past its budget or
inlines the router, React or the SDK (checked on the resolved import graph, with a negative control that inlines a peer on purpose). The shared external list is src/peer-externals.ts.
