Generate a typed SDK

5 min read

Because your content is typed at the source, Mojimoto can hand your front end a matching set of TypeScript types. Your editor autocompletes field names, and a typo becomes a build error instead of a runtime surprise.

Generate the types

The API keys page shows a ready-to-run command with your project and public read token already filled in. Run it to write a types file describing every content type in your model.

terminal
npx @mojimoto/cli types \
  --endpoint https://your-domain.com/api/v1 \
  --project your-project \
  --token mjmt_your_public_read_token

Use them in your app

Each content type becomes a typed document shape. Pull entries from the delivery API and cast them to the generated type — your IDE knows exactly which fields exist.

app.ts
import type { MojimotoDocument, BlogPostData } from './mojimoto-types';

const res = await fetch(
  'https://your-domain.com/api/v1/your-project/documents?type=blog_post',
  { headers: { Authorization: `Bearer ${process.env.MOJIMOTO_TOKEN}` } },
);

const { results } = await res.json() as {
  results: MojimotoDocument<'blog_post', BlogPostData>[];
};

// results[0].data.title is fully typed

Re-run the command whenever your model changes — or in CI — so your types never drift from your content.

Next

Build it for real

Spin up a project and try this in your own space — free for 14 days.

© 2026 Mojimoto, Inc. 文 · モジモト