Interface: CartCookieStore
Cookie I/O port. Caller's responsibility — core never touches document.cookie.
Three methods form a cohesive lifecycle (read existing, write new, clear after expiry). Implementations:
- Browser:
createBrowserCartCookieStore()(from@doswiftly/storefront-sdk/react) - Next.js Server Component / Route Handler: wrap
cookies()fromnext/headers - React Native / mobile: AsyncStorage adapter
- CLI / Node: file-based or in-memory
Map<string, string> - Tests: in-memory stub
Methods
clear()
clear():
void
Removes the cookie. Called when the current cart became unrecoverable.
Returns
void
get()
get():
string|null
Returns the persisted cart id or null. Must be synchronous.
Returns
string | null
set()
set(
cartId,options?):void
Persists the cart id. When options.secret is provided the implementation
stores the composite <cartId>.<secret> value — the cart access secret is
revealed only on create / recovery redeem, so this is the only place it is
written. options.maxAge defaults to platform CART_COOKIE_MAX_AGE.
Parameters
cartId
string
options?
maxAge?
number
secret?
string | null
Returns
void