httpOnlyCookieStorage
Builds a backed by a single HttpOnly cookie on the
Next.js request/response. Server-only by construction — cookies() is the
App Router primitive and is unavailable in client components.
The default settings target a Shopify-style "sticky cart" UX: 180-day
maxAge, sameSite=lax, secure in production, path=/. Reads reject
empty strings and values longer than so that
forged or corrupted cookies never reach the adapter.
Signature
function httpOnlyCookieStorage(opts: HttpOnlyCookieStorageOpts): CartIdStorage;Parameters
| Name | Type | Description |
|---|---|---|
opts | HttpOnlyCookieStorageOpts |
Returns
A implementation suitable for cart-next's reader, ensurer, and typed-action factories.
Example
const actions = createTypedCartActions({
kernel,
storage: httpOnlyCookieStorage({ name: 'my-shop-cart' }),
resolveContext: async ({ idempotencyKey } = {}) => ({ shop, locale, idempotencyKey }),
});Related
AuthBridge CartIdStorage CreateTypedCartActionsOpts FormCartActions HttpOnlyCookieStorageOpts NextEventBridge TypedCartActions NextEventBridgeHandlers
HttpOnlyCookieStorageOpts
Options bag for . Every field is optional — the factory applies defaults tuned for a Shopifystyle stickycart: 180day maxAge, sameSite=lax, secure in production,
NextEventBridgeHandlers
Perevent handler map passed to . Each key is a discriminant; TypeScript infers the narrowed event payload for that variant so handlers receive the concrete fiel