Compile Targets
Write once in KERN. Compile to 15 concrete targets from the current compiler config.
How targets work
The --target flag tells the KERN compiler which framework to emit. Your .kern source stays the same — the compiler handles imports, idioms, and conventions for each target.
kern dev app.kern --target=nextjs --outdir=app/
kern dev app.kern --target=web
kern dev api.kern --target=express
kern dev api.kern --target=fastapi
kern dev server.kern --target=mcpEvery target reads the same AST and applies its own code generation pass. Shared logic (types, machines, configs) compiles identically across targets. UI and routing nodes adapt to each framework's conventions. Some advanced language features are target-dependent; the capability matrix tracks support as native, lowered, or unsupported.
Available targets
Library
--target=lib · TypeScript
Shared library output for reusable types, functions, and modules
Covered in overviewNext.js
--target=nextjs · TypeScript
App Router, metadata, server components, route conventions
Learn more →Python
--target=python · Python
Portable Python lowering for supported language constructs
Covered in overviewGo
--target=go · Go
Portable Go lowering for supported language constructs
Covered in overviewTarget-specific configuration
Create a kern.config.ts at your project root to set defaults and target-specific options.
import { defineConfig } from '@kernlang/cli';
export default defineConfig({
target: 'nextjs',
outdir: 'app/',
frameworkVersions: {
next: '15',
react: '19',
},
structure: {
// Emit route-based directories (features/page.tsx)
routeDirs: true,
// Co-locate loading.tsx / error.tsx with page.tsx
conventions: true,
},
});When kern.config.ts is present, the CLI reads it automatically. You can still override any option via flags: kern dev app.kern --target=vue overrides the config target.
Choosing a target
Pick the target that matches your runtime.
Full-stack web
Use Next.js for apps that need SSR, metadata, and file-based routing. Use Nuxt if your team prefers Vue.
Client-only UI
Use React for SPAs and embedded components. Add Tailwind when your project already uses utility-first CSS. Use Vue for Vue 3 standalone components.
React web output uses --target=web in the current compiler. The docs route stays /docs/targets/react for existing links.
Mobile
Use React Native for iOS and Android. KERN maps to View, Text, and StyleSheet automatically.
Backend APIs
Use Express for Node.js APIs. Use FastAPI for Python APIs with Pydantic validation and async support.
CLI and terminal
Use CLI for argument-driven tools built on Commander.js. Use Terminal for ANSI output with gradients, spinners, and tables. Use Ink for interactive terminal UIs built with React.