Skip to content

Kinetic

Kinetic turns a .kinetic schema into PostgreSQL SQL, a typed TypeScript client and an embedded SvelteKit admin. Your project keeps its own routes, editor overrides and hooks.

kinetic/schema.kineticthe file you write
  1. kinetic/schema.generated.sqlPostgreSQL bootstrap SQL
  2. src/lib/server/generated/Prisma client for server code
  3. src/lib/kinetic/generated/Typed contract, content client and admin manifest
  4. /adminSvelteKit admin rendered by @kinetic/cms
Run bun run generate to update the generated outputs. Keep custom UI and hooks in project-owned files.

The Book model from the Bukinistika demo, and what each generated layer makes of it.

Schema. An excerpt of the model you write. Attributes in the @kinetic namespace drive the admin.

kinetic/collections/books.kinetic
model Book {
id Int @id @default(autoincrement())
title String @kinetic.label("Заглавие") @kinetic.public
priceCents Int @kinetic.label("Цена (€)") @kinetic.currency("EUR") @kinetic.input("euro") @kinetic.public
stockQuantity Int @map("quantity") @default(0) @kinetic.label("Наличност") @kinetic.public
authors Author[] @relation("BookAuthors") @kinetic.reference @kinetic.label("Автори")
@@kinetic.collection(slug: "books", label: "Книги", area: "catalogue", group: ["Каталог"])
@@kinetic.list([title, priceCents, stockQuantity])
}

SQL. The table in schema.generated.sql. Relation tables and indexes follow it.

kinetic/schema.generated.sql
CREATE TABLE "Book" (
"id" SERIAL NOT NULL,
"sourceId" TEXT,
"title" TEXT NOT NULL,
"priceCents" INTEGER NOT NULL,
"quantity" INTEGER NOT NULL DEFAULT 0,
"shelfLocation" TEXT,
"description" TEXT,
"isbn" TEXT,
"coverFile" TEXT,
CONSTRAINT "Book_pkey" PRIMARY KEY ("id")
);

Typed client. The storefront calls the generated content client. The row type includes the ID and the fields marked @kinetic.public.

src/routes/+page.server.ts
import { content } from '$lib/kinetic/generated/client';
import { authEnabled } from '$lib/server/auth';
import type { PageServerLoad } from './$types';
export const load = (async ({ fetch, url }) => ({
...await content(fetch).list('books', {
q: url.searchParams.get('q') ?? undefined,
page: Number(url.searchParams.get('page') ?? 1)
}),
authEnabled
})) satisfies PageServerLoad;

Admin. The scaffolded SvelteKit route loads CMS data and the collections the admin can access.

src/routes/admin/[...segments]/+page.server.ts
import { cms } from '$lib/server/cms';
import type { Actions, PageServerLoad } from './$types';
export const load = (async (event) => {
const [data, navigation] = await Promise.all([cms.load(event), cms.navigation(event)]);
return { ...data, navigation };
}) satisfies PageServerLoad;
export const actions = cms.actions satisfies Actions;
The Books list and a book editor in the Bukinistika demo
The admin generated from the schema above, running the Bukinistika catalogue.
  • Run the Bukinistika demo with disposable PostgreSQL. Quickstart
  • Define models and work with the generated types. Schema guide
  • Read the latest changes. Changelog