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=mcp

Every 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 overview

Next.js

--target=nextjs · TypeScript

App Router, metadata, server components, route conventions

Learn more →

React

--target=web · TypeScript

Hooks, state, effects, providers, memoization

Learn more →

Tailwind

--target=tailwind · TypeScript

React + Tailwind CSS utility classes

Learn more →

React Native

--target=native · TypeScript

StyleSheet, View, Text, mobile-first

Learn more →

Express

--target=express · TypeScript

Routes, middleware, schema guards, SSE

Learn more →

FastAPI

--target=fastapi · Python

Routes, Pydantic models, async, CORS

Learn more →

Vue

--target=vue · HTML+TS

Vue 3 SFCs with Composition API

Learn more →

Nuxt

--target=nuxt · HTML+TS

Nuxt 3 pages, layouts, server routes

Learn more →

CLI

--target=cli · TypeScript

Commander.js apps with args, flags, commands

Learn more →

Terminal

--target=terminal · TypeScript

ANSI UI, spinners, tables, gradients

Learn more →

Ink

--target=ink · TypeScript

React for terminal, interactive TUIs

Learn more →

MCP

--target=mcp · TypeScript

Model Context Protocol server definitions

Learn more →

Python

--target=python · Python

Portable Python lowering for supported language constructs

Covered in overview

Go

--target=go · Go

Portable Go lowering for supported language constructs

Covered in overview

Target-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.