Skip to content

Documentation · v3.6.0

Content as code.
Hosted by you.

Trokky is a headless CMS written in TypeScript. Your schema is code, your content is yours to read and commit, and your frontend compiles against types generated from the same schema.

terminal
  1. $ brew install trokky/tap/trokky
  2. $ trokky create my-site --template minimal --data filesystem
  3. $ cd my-site && npm install && npm run dev
  4. Studio → http://localhost:3000/studio

One definition

Write the schema once. Everything else follows from it.

The object you export drives storage validation, the editing form in Studio, and the interfaces your frontend compiles against. Rename a field and your build fails, instead of your page.

  1. 01 You write
    schemas/post.ts
    export const postSchema = {
    name: 'post',
    title: 'Post',
    type: 'document',
    fields: {
    title: { type: 'string', title: 'Title', required: true },
    slug: { type: 'slug', title: 'Slug', source: 'title' },
    body: { type: 'richtext', title: 'Body' },
    coverImage: { type: 'media', title: 'Cover image' },
    publishedAt: { type: 'date', title: 'Published at' },
    },
    }
  2. 02 trokky generate-types writes
    src/types/trokky/index.ts
    export interface PostDocument extends BaseDocument {
    _type: 'post'
    title: string
    slug?: string
    body?: RichTextValue
    coverImage?: MediaFieldValue | null
    publishedAt?: string
    }
  3. 03 Studio renders

Principles

  1. 01

    Schemas are code

    Define content in TypeScript. One definition drives storage, validation, the admin UI and the types your frontend compiles against.

  2. 02

    Content you can read

    Documents are JSON on disk by default: open them, diff them, commit them. Move to Postgres or Cloudflare D1 with a configuration change.

  3. 03

    Types that follow the schema

    trokky generate-types derives interfaces from the running server. Rename a field and your frontend stops compiling, instead of stopping working.

  4. 04

    You host it

    An Express app you deploy. No per-seat pricing, no API quota, no export button you hope still works.

Find your way

Organised by what you are trying to do.

Read before you ship Things that will bite you True things about Trokky that are not obvious. Each one has cost somebody a real afternoon.

Trokky — a TypeScript-native headless CMS you host yourself. Open source.