Introduction
Headless CMS client for Better i18n content
The Better i18n Content SDK (@better-i18n/sdk) is a lightweight TypeScript client for fetching content models and entries from your Better i18n project. It connects to the REST API using an API key and returns fully typed responses.
Why use the SDK?
- Zero dependencies — Uses native
fetch(), works in any JavaScript runtime - Type-safe — Full TypeScript types with generic custom fields support
- Language-aware — Fetch localized content by language code with automatic fallback
- Pagination — Built-in pagination with total count and
hasMoreindicator - Chainable API — Supabase-style
from()query builder with filtering & sorting
Quick Example
import { createClient } from "@better-i18n/sdk";
const client = createClient({
project: "acme/web-app",
apiKey: process.env.BETTER_I18N_API_KEY!,
});
// List content models
const models = await client.getModels();
// Get published blog posts
const { data: posts, total } = await client
.from("blog-posts")
.eq("status", "published")
.order("publishedAt", { ascending: false })
.limit(10);
// Get a single entry in French
const { data: post } = await client
.from("blog-posts")
.language("fr")
.single("hello-world");
console.log(post.title, post.body);Next Steps
Getting Started
Install the SDK and fetch your first content
Models & Entries
Query content with the chainable from() API
API Reference
Complete method and type reference
TypeScript
Generic custom fields and advanced typing
For AI-powered content management (create, edit, publish), see the MCP Content Server instead.