Getting Started
Use Localess without a frontend framework — a type-safe TypeScript client for fetching content, translations, and assets from any Node.js server or script.
Package: @localess/client
The @localess/client package is the core JavaScript/TypeScript SDK for the Localess headless CMS platform. It provides a type-safe API client for fetching content, translations, and assets, along with Visual Editor integration utilities.
⚠️ Security Notice:
@localess/clientis server-side only, regardless of token type — never import it in a browser bundle, a React Client Component, or any other client-side code, even with a public token. CalllocalessClient()only from code that's never bundled into the browser (a Node script, a server-only module, a Server Component, an API route), and use a secret token there.Production apps should generally use a public token (read-only, published content and translations only) for anything that reaches end users, and keep the secret token for build-time/server-only access — but the public-token case is implemented through a framework SDK's own client-side primitives (
@localess/react'slocalessInit,@localess/angular'sprovideLocaless), never by importing@localess/clientdirectly. If you need browser-safe Localess access, use one of the framework SDKs (@localess/angular,@localess/react,@localess/astro) instead of this package.
Playgrounds:
@localess/clientunderlies every framework integration, so the closest thing to a reference implementation for it is any framework playground — see the Next.js, Angular, or Astro guides, or browseplaygrounds/directly.
Requirements
- Node.js >= 24.0.0
Installation
# npm
npm install @localess/client@latest
# yarn
yarn add @localess/client@latest
# pnpm
pnpm add @localess/client@latestGetting Started
Initializing the Client
import { localessClient } from "@localess/client";
const client = localessClient({
origin: 'https://my-localess.web.app', // Fully qualified domain with protocol
spaceId: 'YOUR_SPACE_ID', // Found in Localess Space settings
token: 'YOUR_API_TOKEN', // Found in Localess Space settings (keep secret!)
});Client Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
origin | string | Yes | — | Fully qualified domain with protocol (e.g., https://my-localess.web.app) |
spaceId | string | Yes | — | Localess Space ID, found in Space settings |
token | string | Yes | — | Localess API token, found in Space settings |
version | 'draft' | string | No | 'published' | Default content version to fetch |
debug | boolean | No | false | Enable debug logging |
cacheTTL | number | false | No | 300 | Cache TTL in seconds (5 minutes). Set false to disable caching entirely |
AI Coding Agents
This package ships a SKILL.md file that provides AI coding agents (GitHub Copilot, Claude Code, Cursor, and others) with accurate, up-to-date APIs, patterns, and best practices.
Reference it from your project's AGENTS.md:
## Localess
@node_modules/@localess/client/SKILL.md