Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
commercengine avatar

Ce Ssr

  • 10 installs
  • Updated March 18, 2026
  • commercengine/skills

Builds custom SSR bindings for Commerce Engine with @commercengine/ssr-utils for frameworks like Nuxt that lack a first-party wrapper.

About

Builds custom SSR bindings for Commerce Engine using ssr-utils for unsupported frameworks such as Nuxt. A developer uses it to wire cookie and token storage where no first-party wrapper exists.

  • CookieAdapter and ServerTokenStorage via @commercengine/ssr-utils
  • Public vs session patterns for Nuxt and other unsupported frameworks

Ce Ssr by the numbers

  • 10 all-time installs (skills.sh)
  • Ranked #3,590 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Jul 29, 2026 (Skillselion catalog sync)
npx skills add https://github.com/commercengine/skills --skill ce-ssr

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs10
Last updatedMarch 18, 2026
Repositorycommercengine/skills

What it does

Builds custom SSR bindings for Commerce Engine with @commercengine/ssr-utils for frameworks like Nuxt that lack a first-party wrapper.

Files

SKILL.mdMarkdownGitHub ↗
LLM Docs Header: All requests to https://llm-docs.commercengine.io must include the Accept: text/markdown header (or append .md to the URL path). Without it, responses return HTML instead of parseable markdown.

Custom SSR Bindings (@commercengine/ssr-utils)

Prerequisite: SDK initialized. See setup/.

When to Use This Skill

Use @commercengine/ssr-utils only for frameworks that do not have a first-party Commerce Engine wrapper:

FrameworkWhat to Use
Next.js@commercengine/storefront/nextjs → see ssr-patterns/
TanStack Start@commercengine/storefront/tanstack-start → see ssr-patterns/
Astro@commercengine/storefront/astro → see ssr-patterns/
SvelteKit@commercengine/storefront/sveltekit → see ssr-patterns/
Nuxt@commercengine/ssr-utilsthis skill

Why This Matters

The SDK model splits public reads from live session flows:

  • PublicStorefrontSDK / storefront.public() for public build/prerender reads
  • SessionStorefrontSDK / storefront.session(...) for live anonymous or logged-in user flows

@commercengine/ssr-utils exists only for the second case. It provides cookie-backed request storage for building custom framework bindings.

Quick Reference

ConceptWhat It Does
CookieAdapterNormalizes framework cookie APIs into { get, set, delete }
ServerTokenStorageImplements TokenStorage using any CookieAdapter
createCookieAdapter(...)Helper for frameworks whose cookie store already has compatible get / set / delete methods

Decision Tree

User Request: "Add SSR support" / "Cookie-based auth" / "Server-side rendering"
    │
    ├─ Next.js?
    │   └─ YES → Use @commercengine/storefront/nextjs → see ssr-patterns/
    │
    ├─ TanStack Start?
    │   └─ YES → Use @commercengine/storefront/tanstack-start → see ssr-patterns/
    │
    ├─ Astro?
    │   └─ YES → Use @commercengine/storefront/astro → see ssr-patterns/
    │
    ├─ SvelteKit?
    │   └─ YES → Use @commercengine/storefront/sveltekit → see ssr-patterns/
    │
    ├─ Public build/prerender read?
    │   └─ YES → Use PublicStorefrontSDK / storefront.public()
    │
    ├─ Live request with cookies? (Nuxt, etc.)
    │   └─ Create CookieAdapter → ServerTokenStorage → SessionStorefrontSDK
    │
    └─ Optional: wrap the base config in your own framework helper

Architecture

Public render / prerender
  └─ PublicStorefrontSDK
     └─ API key only
     └─ No token bootstrap, refresh, or cookie writes

Live SSR request
  └─ SessionStorefrontSDK
     └─ tokenStorage: ServerTokenStorage(adapter)
     └─ Reads and writes request cookies
     └─ Can bootstrap anonymous auth and refresh tokens

Installation

npm install @commercengine/storefront @commercengine/ssr-utils

Key Patterns

1. Build the CookieAdapter

Nuxt / h3

import { deleteCookie, getCookie, setCookie } from "h3";

const adapter = {
  get: (name: string) => getCookie(event, name) ?? null,
  set: (name: string, value: string, options?: Parameters<typeof setCookie>[3]) =>
    setCookie(event, name, value, options),
  delete: (name: string) => deleteCookie(event, name),
};
Note: SvelteKit and Astro now have first-party wrappers (@commercengine/storefront/sveltekit and @commercengine/storefront/astro). Use those instead of building custom adapters. See ssr-patterns/.

2. Create ServerTokenStorage

import { ServerTokenStorage } from "@commercengine/ssr-utils";

const tokenStorage = new ServerTokenStorage(adapter, {
  prefix: "myapp_",
  maxAge: 2592000,
  path: "/",
  sameSite: "lax",
});

3. Create the session SDK

import { SessionStorefrontSDK } from "@commercengine/storefront";

const sdk = new SessionStorefrontSDK({
  storeId: "your-store-id",
  apiKey: "your-api-key",
  tokenStorage,
});

4. Public render SDK

For build-time or public SSR reads, do not go through ServerTokenStorage at all:

import { PublicStorefrontSDK } from "@commercengine/storefront";

const publicSdk = new PublicStorefrontSDK({
  storeId: "your-store-id",
  apiKey: "your-api-key",
});

const { data } = await publicSdk.catalog.listProducts();

5. Session bootstrap

If a custom SSR binding wants to establish the session eagerly at the start of a live request, use the session SDK:

await sdk.ensureAccessToken();
const { data } = await sdk.cart.getWishlist();

For ordinary session-aware SDK calls such as sdk.cart.getWishlist(), sdk.cart.addToWishlist(), sdk.cart.getUserCart(), or sdk.customer.listAddresses(), you do not need to call ensureAccessToken() first. The session middleware and overloads handle session creation and user_id / customer_id resolution automatically.

Hosted Checkout Token Sync (SSR)

If Hosted Checkout is present, the Storefront SDK should remain the session owner. Wire onTokensUpdated so the checkout runtime stays in sync on the client side.

const sdk = new SessionStorefrontSDK({
  storeId: "...",
  apiKey: "...",
  tokenStorage,
  onTokensUpdated: (accessToken, refreshToken) => {
    if (typeof window !== "undefined") {
      import("@commercengine/checkout").then(({ getCheckout }) => {
        getCheckout().updateTokens(accessToken, refreshToken);
      });
    }
  },
});

Common Pitfalls

LevelIssueSolution
CRITICALUsing BrowserTokenStorage in SSR codeUse ServerTokenStorage
CRITICALUsing session SDK for build/prerender public pagesUse PublicStorefrontSDK or storefront.public()
HIGHUsing ssr-utils directly in Next.js, TanStack Start, Astro, or SvelteKitUse the first-party wrappers: @commercengine/storefront/nextjs, /tanstack-start, /astro, or /sveltekit
HIGHClient and server cookie formats driftingKeep prefix, path, secure, sameSite, and encoding aligned
MEDIUMScattering ensureAccessToken() across feature codeIf you want eager bootstrap, centralize it in one request bootstrap/helper instead of calling it before every cart/auth/customer method

See Also

  • setup/ - SDK installation and framework detection
  • ssr-patterns/ - First-party SSR patterns for Next.js, TanStack Start, Astro, and SvelteKit
  • auth/ - Authentication flows
  • cart-checkout/ - Hosted Checkout sync details

Documentation

  • Token Management: https://www.commercengine.io/docs/sdk/token-management
  • LLM Reference: https://llm-docs.commercengine.io/sdk/

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.