Project structure#
A Kiln app is a directory with a few known folders and file names. Kiln reads that layout directly. There is no route file to maintain.
The default layout#
my-app/
app/
pages/ Page files. Each file becomes a route.
_layout.tsx Layout for every page.
index.tsx The home page at /.
about.tsx The page at /about.
about.server.tsx A page that renders only on the server.
(marketing)/ A route group. Affects layouts, not the URL.
blog/[slug].tsx A page with a dynamic segment.
docs/[...path].md A Markdown page with a catch-all segment.
_error.tsx Shown when a page throws.
_not-found.tsx Shown when no route matches.
api/ API route files. Each file becomes an endpoint.
health.ts The endpoint at /api/health.
components/ Shared components. Not routes.
client.tsx Optional. Custom browser entry.
server.ts Optional. Custom server entry.
markdown.tsx Optional. Maps Markdown tags to components.
.kiln/ Generated by the CLI. Do not edit.
env.d.ts Type declarations for <kiln:title>.
client.tsx Generated browser entry when you have no app/client.tsx.
server.ts Generated server entry when you have no app/server.ts.
vite.config.ts Vite configuration.
package.json
tsconfig.json
.env Environment variables. Optional.Pages#
Anything under app/pages that ends in .tsx, .jsx, .ts, .js, or .md can be a route. Files whose names start with an underscore are not routes. They are special files such as _layout, _error, and _not-found.
The file name controls the route and the render mode. See Routing and Rendering modes.
API routes#
Anything under app/api that ends in .tsx, .jsx, .ts, or .js is an API route. Files are not rendered as pages and cannot be .md. Each exported function named after an HTTP method (GET, POST, and so on) handles that method. See API routes.
Components#
Files outside app/pages and app/api are normal modules. Put shared UI there and import it from pages. If a component carries the directive "use island" at the top of the file, Kiln treats it as an island. See Islands.
Client and server entries#
Kiln generates both entries if you do not write them. Write app/client.tsx or app/server.ts only when you need to change them. Kiln looks for client and server with the extensions tsx, ts, jsx, and js, in that order.
The default server entry looks like this:
import { createAppHandler, type KilnAssets } from "@kiln-js/server";
export function createHandler(assets: KilnAssets) {
return createAppHandler({ assets });
}The default client entry looks like this:
import { createClient } from "@kiln-js/client";
createClient().then((client) => client.start());The .kiln folder#
The CLI writes generated files into .kiln on every run. Commit it or ignore it as you prefer, but do not edit it. The env.d.ts file in there is what lets TypeScript accept <kiln:title> in JSX.
Build output#
kiln build writes three folders at the project root:
dist/client: browser assets, including the Vite manifest that maps source files to hashed names.dist/server: the server bundle, a single file namedserver.js..vercel/output: produced only with--target vercel.

