Skip to content

Schema and generated code

The schema option in kinetic.config.ts points to the entry file. Put related models in separate .kinetic files and import them relative to that entry or another schema file.

import "./collections/books.kinetic"
datasource db {
provider = "postgresql"
}

Expose a model to the CMS with @@kinetic.collection. Mark individual fields with @kinetic.public to include them in the public API.

model Book {
id Int @id @default(autoincrement())
title String @kinetic.public
@@kinetic.collection(slug: "books", label: "Books")
@@kinetic.list([title])
}

Run bun run generate from the repository root. Generation updates the SQL, client, and CMS metadata and then type-checks the SvelteKit app.

Output in the experiment Use it for
kinetic/schema.generated.sql Bootstrap a fresh PostgreSQL database.
src/lib/server/generated/ Server-side queries through the typed database client.
src/lib/kinetic/generated/ CMS metadata, typed hooks and inputs, navigation, and the public HTTP client.
src/routes/admin/[...segments]/ Mount the CMS in a project-owned SvelteKit route.

Use the HTTP client in a SvelteKit load function where fetch is available. Sort and filter options are restricted to the public scalar projection.

import { content } from '$lib/kinetic/generated/client';
const books = await content(fetch).list('books', {
sort: { field: 'title', direction: 'asc' }
});

Keep UI overrides in the project-owned src/lib/kinetic/admin.ts and inputs.ts. Put mutation hooks in the CMS server configuration. The Bukinistika experiment registers its editor sections in admin.ts and passes its hooks to createCms in src/lib/server/cms.ts.

Regeneration preserves these project files and the scaffolded routes. If you remove a field or change its type, incompatible overrides, hooks, and queries fail type-checking.

For settings, add @@kinetic.singleton to the model. The CMS opens its editor directly. The generated singletons.server.ts exposes typed get, initialize, and update methods. PostgreSQL enforces a maximum of one row. Migration behavior