Quick start
Install tomekit, define a collection, read it typed.
tomekit parses and validates your Markdown while Vite builds, then serves it as a generated module. Your pages read typed data, and nothing parses Markdown at runtime.
Automatic
Paste this prompt into your coding agent, eg Claude Code, Codex or Cursor. It does every step under Manual for you and runs the build until it passes.
Manual
1. Install
pnpm add tomekit zodZod is the validator used below. Any Standard Schema validator works, eg Valibot or ArkType.
2. Add the plugin
import { tomekit } from "tomekit/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [tomekit()],
});3. Add the types path
tomekit writes the generated module and its types to .tomekit. Point tomekit/content* at it in tsconfig.json, and add .tomekit to .gitignore:
{
"compilerOptions": {
"paths": { "tomekit/content*": ["./.tomekit/content*"] }
}
}4. Define a collection
A collection is a named set of documents that share one loader, which says where they come from, and one schema, which every document's metadata must satisfy. Put them in tomekit.config.ts at the project root:
import { defineConfig, directory } from "tomekit";
import { z } from "zod";
export default defineConfig({
collections: {
posts: {
loader: directory("content/posts"),
schema: z.strictObject({ title: z.string(), date: z.coerce.date() }),
},
},
});directory() reads every Markdown file under content/posts. Each file becomes one document: its frontmatter is the metadata, the text below is the body, and its path without the extension is the slug.
---
title: Hello world
date: 2026-09-16
---
The first post.5. Read it
import { posts } from "tomekit/content";
const post = posts.get("hello-world");
post.metadata.title; // string
post.metadata.date; // Date, because the schema coerced it
post.body; // "The first post."Both names are checked: posts comes from your config and "hello-world" from your files, so a typo is a type error, not a missing page. Content is read when Vite builds, so a new post shows up after a rebuild. Read collections from server code only, or their documents ship to the browser.
6. Set up AGENTS.md
The package ships a guide for coding agents at node_modules/tomekit/dist/AGENTS.md, matching the version you installed. Paste this into AGENTS.md at your project root, so agents read it before writing tomekit code:
In a monorepo, start the path from the root, eg apps/web/node_modules/tomekit/dist/AGENTS.md.
That is the whole setup. Collections covers loaders and schemas, Transform does the parsing once, at build time, and TanStack Start, React Router and SolidStart put both into a blog.
Requirements
Vite 8, TypeScript 7 and Node 24, or later.