← All packages

@lacspace/sdk

v2.2.0Core3 @lacspace deps

High-level TypeScript SDK for Lacspace — api, auth, analytics and e-commerce sharing one connection and token. Now with named environment presets, a config merger, correlation/idempotency ids, health probes, typed error normalization and transport-agnostic pagination.

npm i @lacspace/sdk

Usage

sdk.ts
import { LacspaceSDK } from "@lacspace/sdk";

const lac = new LacspaceSDK({ baseURL: "https://api.lacspace.com/api" });

// 1 · Authenticate — the token is stored and reused everywhere
const { user } = await lac.auth.login({ email: "you@shop.com", password: "••••••••" });

// 2 · E-commerce helpers
const products = await lac.ecommerce.getProducts();
await lac.ecommerce.addToCart({ productId: products[0]!.id, quantity: 1 });
const { orderId } = await lac.ecommerce.checkout("cart_123");

// 3 · Track what happened
await lac.analytics.track("checkout_completed", { orderId });

Exports 12

LacspaceAnalyticsLacspaceApiLacspaceApiErrorLacspaceAuthLacspaceSDKcreateAnalyticscreateApicreateAuthcreateClientisApiErrorlocalStorageTokenStoragememoryTokenStorage

Keywords

lacspacesdkecommerceauthanalyticstypescriptcorrelation-ididempotency-keyhealth-checkenvironment-config

More in Core

@lacspace/analytics

Event tracking for Lacspace platforms — a spec-style track/identify/page/group/alias client with batching, an offline retry queue, consent + Do-Not-Track gating, and pluggable middleware. Every transport, clock and timer is injectable, so it never touches the network by default.

@lacspace/analytics-lite

Privacy-first, cookieless web analytics — page views and custom events sent to your own endpoint. No cookies, no localStorage IDs, no cross-site tracking, no consent banner. Respects Do-Not-Track, auto-tracks SPA navigation, uses sendBeacon. Now with a batching LiteClient, a sendBeacon-first transport, UTM parsing, DNT/consent helpers and a CSPRNG id. Zero-dependency, isomorphic.

@lacspace/api

Lightweight, zero-dependency, isomorphic TypeScript HTTP client for Lacspace APIs — retries with backoff, interceptors, timeouts/abort, page- & cursor-pagination, plus dependency-free query-string, URL/path, header-merge, form-body and typed-error helpers.

@lacspace/auth

Authentication flows (login, register, token, refresh) for Lacspace APIs — now with PKCE/OIDC helpers, JWT expiry math, scope/role checks and proactive token refresh.

@lacspace/next

Next.js App Router integration for the Lacspace SDK — authenticated server client from cookies, Route Handler/Server Action wrappers, CSRF + middleware auth guard, plus edge-safe pure helpers for cookies, Cache-Control, route matching, open-redirect-safe redirects and bearer tokens.

@lacspace/react

React hooks and provider for the Lacspace SDK — useAuth, useQuery, useMutation, useAuthStatus and useLacspace, all sharing one authenticated client, over a pure DOM-free core (async state machine, retry/backoff, polling) you can unit-test anywhere.