Client
Browser and Server client setup guide
Client
The SDK provides two types of clients depending on your environment.
BrowserClient
A read-only client for browser environments (Client Components).
import { createBrowserClient } from '@01.software/sdk'
export const client = createBrowserClient({
clientKey: process.env.NEXT_PUBLIC_SOFTWARE_CLIENT_KEY!
})| Property | Description |
|---|---|
from(collection) | Returns ReadOnlyQueryBuilder (find, findById, count) |
customer | Customer authentication (register, login, me, logout, ...) |
cart | Cart API (addItem, updateItem, removeItem) — requires customer auth |
query | React Query hooks (6 read + 3 mutation + 9 customer + prefetch + cache) |
queryClient | TanStack QueryClient instance |
ServerClient
A client for server environments (Server Components, API Routes, Server Actions).
import { createServerClient } from '@01.software/sdk'
export const serverClient = createServerClient({
clientKey: process.env.NEXT_PUBLIC_SOFTWARE_CLIENT_KEY!,
secretKey: process.env.SOFTWARE_SECRET_KEY!,
})The secretKey must never be exposed to the browser!
In addition to all BrowserClient properties, it provides:
| Property | Description |
|---|---|
from(collection) | Returns CollectionQueryBuilder (read + create, update, remove, updateMany, removeMany) |
api | Orders API (9 methods: order, transaction, fulfillment, return) |
cart | Cart API (addItem, updateItem, removeItem) |
product | Product API (stockCheck) |
Configuration Options
const client = createBrowserClient({
clientKey: string, // Required: API client key
environment?: Environment, // 'local' | 'production' (default: 'production')
baseUrl?: string, // API URL override (default: https://api.01.software)
customer?: { // Customer authentication
token?: string, // Initial token (e.g. from localStorage)
onTokenChange?: (token: string | null) => void, // Persist on login/logout
},
})Priority: baseUrl > environment variable (SOFTWARE_API_URL) > environment > production