httpOnlyCookieStorage

cart · /next·function

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

@nordcom/commerce-cart

Parameters

NameTypeDescription
optsHttpOnlyCookieStorageOpts

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 }),
});

AuthBridge CartIdStorage CreateTypedCartActionsOpts FormCartActions HttpOnlyCookieStorageOpts NextEventBridge TypedCartActions NextEventBridgeHandlers

On this page