Creating Framework Adapters
Kiln’s core compiler is framework-agnostic. All framework-specific build output conventions are encapsulated in FrameworkAdapter implementations.
The FrameworkAdapter Interface
Section titled “The FrameworkAdapter Interface”import type { FrameworkAdapter } from "kiln-compiler";
export interface FrameworkAdapter { readonly framework: string; readonly name: string;
detect(projectDir: string): boolean; getStandaloneDir(projectDir: string): string; getDistDir(projectDir: string): string; getStaticAssetConfig(): { dir: string; urlPrefix: string }; getStubs(): readonly StubModule[]; getBuildDefines(): readonly string[]; generateServerEntry(ctx: ServerEntryContext): string;}Step-by-Step Guide
Section titled “Step-by-Step Guide”- Create Adapter File: In
packages/kiln/src/adapter/<framework>/index.ts. - Implement Detection: Check for config files (
astro.config.mjs,vite.config.ts, etc.). - Configure Asset Paths: Map static assets (
client/) and runtime chunks (server/). - Generate Server Entry: Return the runtime JavaScript source that starts your framework’s server.
- Register Adapter: In
packages/kiln/src/adapter/registry.ts:registerAdapter({framework: "my-framework",create: () => createMyAdapter(),});
