@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 If your framework’s cookie store already has compatible methods, use
{ get, set, delete }. For Nuxt, that means wrapping h3:createCookieAdapter(...) instead of hand-writing this.2
Create the token storage
3
Create the session SDK
Public reads
For build-time and public SSR reads, skipServerTokenStorage entirely — there is no session to carry:
Session bootstrap
Session-aware calls resolve the session themselves. The middleware handles session creation anduser_id / customer_id resolution, so you do not need to bootstrap before every call:
ensureAccessToken() once in a request bootstrap helper:
Hosted Checkout token sync
When Hosted Checkout is present, the Storefront SDK stays the session owner. WireonTokensUpdated 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.