Krate Docs

Configuration

Krate is configured with a krate.config.ts file at the project root, typed with defineConfig from @krate/core. Every supported key is type-checked — unknown or misspelled options become compile errors.

import { defineConfig, sitemap, docs } from '@krate/core'; export default defineConfig({ entry: "src/index.tsx", outDir: "dist", pagesDir: "src/pages", minify: true, tailwind: { enabled: false, scanDirs: ["src"] }, redirects: [{ source: "/old", destination: "/new", permanent: true }], plugins: [ sitemap({ baseUrl: "https://example.com" }), docs({ contentDir: "content/docs", title: "Docs" }), ], });

Build options

OptionTypeDefaultDescription
entrystringsrc/index.tsxEntry point
outDirstringdistOutput directory
pagesDirstringsrc/pagesPages directory
publicDirstringpublicStatic assets directory
minifybooleantrueEnable all minification
minifyHTMLbooleaninherits minifyHTML minification
minifyCSSbooleaninherits minifyCSS minification
minifyJSbooleaninherits minifyJS minification
sourcemapbooleanfalseWrite per-page sourcemaps (index.<hash>.js.map)
emitReactbooleanfalseReact compatibility mode (rewrites React → krate)

Runtime

OptionTypeDefaultDescription
runtime\`"node" \"bun" \"deno"\`nodeRuntime for the API routes sidecar

Dev server

devServer: { port: 3000, open: true, }

Tailwind CSS

tailwind: { enabled: false, scanDirs: ["src"], }

Krate's Tailwind is Go-native (no PostCSS). The class scanner extracts class names from source files and maps them to rules from a built-in rule set. It supports variants (hover:, focus:, responsive breakpoints, dark:) and arbitrary values (w-[100px], bg-[#ff0000]). Configuration lives in tailwind.config.ts (executed via npx tsx).

Markdown

markdown: { gfm: true, headingAnchors: true, admonitions: true, codeHighlight: true, math: false, }

Content Security Policy

csp: { enabled: false, directive: "", // custom CSP string (empty = auto-generate) }

When enabled, krate computes SHA-256 hashes of inline scripts and styles and emits them in the CSP meta tag.

SSR / Streaming

ssr: { streaming: false, // force ALL pages to streaming SSR rendererPort: 0, // Node renderer port (0 = default) timeout: 5000, // max render time (ms) maxCacheSize: 128, // ISR in-memory cache size middlewareRuntime: "quickjs", // middleware.ts runtime apiRuntime: "quickjs", // API route runtime }

middlewareRuntime and apiRuntime select the runtime that executes middleware and API routes: "quickjs" (default) uses the embedded QuickJS runtime (no Node.js needed), while "node", "bun", or "deno" uses a sidecar process. The top-level runtime option controls which sidecar runtime API routes use.

Redirects & rewrites

redirects: [ { source: "/old-page", destination: "/new-page", permanent: true }, ], rewrites: [ { source: "/docs/:path*", destination: "/documentation/:path*" }, ],

Redirects produce 301/302 responses; rewrites map URLs to internal paths.

Component tiers

serverComponents: ["DataTable"], // names to treat as @server runtimeComponents: ["AuthCheck"], // names to treat as @runtime serverDirs: ["src/components/server"], runtimeDirs: ["src/components/runtime"],

Plugins

plugins: [ sitemap({ baseUrl: "https://example.com" }), docs({ contentDir: "content/docs", title: "Docs" }), demoPlugin({ greeting: "Hello!" }), ]

Built-in plugins use factory functions (sitemap, docs); community plugins are imported from local modules and take their own options object. Plugins run in order sequence (lower first).

SEO & robots

seo: { baseUrl: "https://example.com", siteName: "Krate", description: "A modern static site generator", }, robots: { allow: "/", }

See the Config Reference for every supported key.