Quick start#
This guide creates a Kiln app, runs it in development, adds a page and an API route, and builds it for production.
1. Create the app#
bunx @kiln-js/cli create my-appThe command asks you a short series of questions:
- Project name. Letters, numbers,
-, and_are allowed. - Template.
Minimalcreates one page.Starteradds an about page and a layout.Blogadds route groups, a loader, and a pricing page. - Rendering mode for the home page.
universal(the default) renders on the server and hydrates in the browser.serversends HTML only.clientrenders only in the browser. - Example API route. When you accept, the project includes
app/api/health.ts. - Extras. An
.envfile, and custom client and server entries. - Install dependencies now. When you accept, the CLI runs
bun install.
When it finishes, it prints the next command.
2. Run the development server#
cd my-app
bun run devThis runs kiln dev, which starts on port 3000 by default. Change the port with --port:
bun run dev -- --port 4000The development server renders pages on the server, hot-reloads the browser when a client file changes, and reloads the page when you add or remove a route file. When a page throws, the error appears in an overlay with the failing file, a code frame, and the stack trace.
3. Add a page#
Create app/pages/about.tsx:
import { Link } from "@kiln-js/client";
export default function About() {
return (
<main>
<kiln:title>About</kiln:title>
<h1>About this app</h1>
<p>This page is served at /about.</p>
<Link href="/">Back home</Link>
</main>
);
}Save the file. The route /about now exists. You do not need to edit any route table.
You can also generate the file with the CLI:
bunx kiln generate page about4. Add a loader#
A loader runs on the server before the page renders and supplies its data prop. Create app/pages/posts/[slug].tsx:
export async function loader({ params }: { params: Record<string, string> }) {
return { slug: params.slug, title: `Post: ${params.slug}` };
}
export default function Post({ data }: { data: { slug: string; title: string } }) {
return (
<article>
<kiln:title>{data.title}</kiln:title>
<h1>{data.title}</h1>
</article>
);
}The URL /posts/hello matches [slug] and passes params.slug to the loader.
5. Add an API route#
Create app/api/hello.ts:
export function GET() {
return Response.json({ message: "hello" });
}Request /api/hello and you receive {"message":"hello"}.
6. Build for production#
bun run build
bun run startkiln build writes the client bundle, the server bundle, and the manifest. kiln start serves the built output on port 3000. The start command also takes --port.
To deploy to Vercel, build with the Vercel target:
bunx kiln build --target vercelSee Deploying for details.
Next steps#
- Read Project structure to learn what each folder does.
- Read Routing and Rendering modes to choose how your pages render.

