Skip to main content
@commercengine/ssr-utils gives you the two pieces you need to wire the Storefront SDK into a server-rendered framework that Commerce Engine does not already ship a wrapper for: a cookie adapter and a server-side token store.
Reach for this package only when your framework has no first-party wrapper. If you are on Next.js, TanStack Start, Astro, or SvelteKit, use the wrapper instead — it does all of this for you and stays in sync with the SDK.

When to use it

Why it exists

The SDK splits public reads from live session flows, and only the second needs cookies:
ssr-utils exists for the live-request case. Public catalog reads never touch it.

What’s in the package

Installation

Build the binding

1

Write a cookie adapter

Map your framework’s cookie API onto { get, set, delete }. For Nuxt, that means wrapping h3:
If your framework’s cookie store already has compatible methods, use createCookieAdapter(...) instead of hand-writing this.
2

Create the token storage

Keep prefix, path, secure, sameSite, and encoding identical between your server and client cookie handling. Drift here produces sessions that silently fail to resume.
3

Create the session SDK

Public reads

For build-time and public SSR reads, skip ServerTokenStorage entirely — there is no session to carry:

Session bootstrap

Session-aware calls resolve the session themselves. The middleware handles session creation and user_id / customer_id resolution, so you do not need to bootstrap before every call:
If you want the session established eagerly at the top of a request instead, call ensureAccessToken() once in a request bootstrap helper:
Centralize eager bootstrap in one place. Scattering ensureAccessToken() through feature code adds a round trip per call site for no benefit.

Hosted Checkout token sync

When Hosted Checkout is present, the Storefront SDK stays the session owner. Wire onTokensUpdated so the checkout runtime follows along on the client:

Common pitfalls

Next steps

Token Management

How the SDK stores, refreshes, and rotates tokens across environments.

Configuration

Every SDK configuration option, including storage selection.