CLI
Types
Generate TypeScript type definitions from your Localess content schemas.
Fetch your space's content schemas directly from the Localess API and generate TypeScript type definitions from them. The output file provides full type safety when working with Localess content in your TypeScript projects.
Schemas are read live from the database — there is no intermediate OpenAPI document — so the generated types always reflect the current state of your space.
localess types generate [--path <output_path>]Options
| Flag | Default | Description |
|---|---|---|
-p, --path <path> | .localess/localess.d.ts | Path to write the generated TypeScript definitions file |
Your API token must have Development Tools permission enabled in Localess Space settings.
Examples
# Generate types to the default location
localess types generate
# Generate types to a custom path
localess types generate --path src/types/localess.d.tsUsing Generated Types
import type { Page, HeroBlock } from './.localess/localess';
import { getLocalessClient } from "@localess/react";
const client = getLocalessClient();
const content = await client.getContentBySlug<Page>('home', { locale: 'en' });
// content.data is now fully typed as Page