Getting started
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.
Install
pnpm add tomekit zodZod is the validator used below. Any Standard Schema validator works, eg Valibot or ArkType.
Add the plugin
import { tomekit } from "tomekit/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [tomekit()],
});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*"] }
}
}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.object({ 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.Read it
import { collections } from "tomekit/content";
const post = collections.get("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. Read collections from server code only, or every document ships to the browser.
That is the whole setup. Collections covers loaders and schemas, Transform does the parsing once, at build time, and TanStack Start puts both into a blog.
Requirements
Vite 8, TypeScript 7 and Node 24, or later.