Skip to main content

TypeScript SDK

A 100% type-safe TypeScript SDK for the CommerceEngine Storefront API — automatic token management, universal compatibility (browser, Node.js, Next.js, TanStack Start, Astro, SvelteKit), and production-ready error handling.

Package

@commercengine/storefront

Universal TypeScript SDK with first-class bindings for React, Next.js, TanStack Start, Astro, SvelteKit, and Node.js.

Install it for me

create-commercengine installs the SDK, picks the right framework binding, and writes the config and .env — for a new storefront or an existing project:

Scaffold a storefront

Three production designs across five frameworks, running in one command.
Prefer to wire it yourself? Everything below is the manual path.

Pick your integration

React

Context providers, hooks, and component patterns for React SPAs.

Next.js

SSR, Server Actions, static rendering, and cookie-backed sessions.

TanStack Start

Server functions, route loaders, and pre-rendering.

Astro

SSR pages, API routes, middleware, and static prerendering.

SvelteKit

Server load functions, form actions, hooks, and universal loads.

Node.js

Express middleware, background jobs, and server-side patterns.

Installation

Quick Start

1

Initialize the SDK

lib/storefront.ts
2

Browse products (public — no auth needed)

3

Start a session for cart, auth, and orders

That’s it — you’re making API calls. The SDK handles token refresh, error typing, and session management automatically.

Learn More

Client Overview

Public/session split, available clients, and the SDK architecture.

Configuration

All config options, environments, custom base URLs, and debugging.

Token Management

Automatic token refresh, storage options, and auth lifecycle.

Type Safety

Auto-generated types, IntelliSense, and the { data, error } pattern.