Project tour
The files in a scaffolded kitcms app and which ones are yours to edit.
On this page
This page walks through the files of a scaffolded app, so you know which ones are yours to edit.
The blank template
my-site/
src/
kitcms.config.ts your schema
kitcms.admin.ts live preview components
kitcms.rpc.ts the Service Binding entrypoint
hooks.server.ts installs kitcms
app.d.ts registers the config type
routes/
+page.server.ts reads content with locals.cms
(kitcms)/admin/ generated admin route
(kitcms)/api/ generated API route
migrations/ SQL migrations (created by kitcms)
drizzle/schema.ts generated Drizzle schema (created by kitcms)
wrangler.jsonc Worker, D1 and R2 bindings
vite.config.ts SvelteKit plus the kitcms Vite plugin
.dev.vars local secrets (not committed)Files you edit
src/kitcms.config.tsis the only place the schema exists. See Configuration.src/kitcms.admin.tsregisters live preview components. They run in the browser, which is why they are not in the config. See Live preview.src/routes/is your site. Load content withlocals.cmsin+page.server.tsfiles.wrangler.jsoncholds the bindings. Keep the binding namesDBandBUCKET, or setbindingsin the config to match your names.
Files kitcms generates
Do not edit these. They start with a GENERATED comment.
src/routes/(kitcms)/admin/[...path]/renders the admin from@kitcms/uiand re-exportsloadandactionsfrom@kitcms/core/sveltekit/admin.src/routes/(kitcms)/api/[...path]/+server.tsre-exportsGET,POST,PATCHandDELETEfrom@kitcms/core/sveltekit/api. It serves the REST API, uploads, media and plugin endpoints.src/kitcms.rpc.tsexports theKitcmsRPCclass that other Workers bind to. It must stay a class declaration, because wrangler finds entrypoints by exported classes.drizzle/schema.tsandmigrations/come fromkitcms migrate:create.
The wiring
src/hooks.server.ts installs kitcms. It sets locals.cms for every request:
src/hooks.server.ts
import { kitcms } from '@kitcms/core/sveltekit';
import config from './kitcms.config';
export const handle = kitcms({ config }).handle;src/app.d.ts registers the config type, which is what types locals.cms:
src/app.d.ts
import type config from './kitcms.config';
declare module '@kitcms/core' {
interface Register {
config: typeof config;
}
}vite.config.ts adds the kitcms Vite plugin and wraps the Cloudflare adapter, so the same Worker also exports KitcmsRPC:
vite.config.ts
import { sveltekit } from '@sveltejs/kit/vite';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { kitcms, kitcmsAdapter } from '@kitcms/core/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [sveltekit({ preprocess: vitePreprocess(), adapter: kitcmsAdapter() }), kitcms()],
});SvelteKit 3 keeps its config in vite.config.ts. There is no svelte.config.js.
Scripts
| Script | Runs |
|---|---|
pnpm dev |
The dev server with local D1 and R2. |
pnpm preview |
pnpm build && wrangler dev: the built Worker under workerd, like production. |
pnpm db:generate <name> |
kitcms migrate:create <name> |
pnpm db:migrate |
kitcms migrate on the local D1. Add --remote for production. |
pnpm types |
kitcms generate:types |
pnpm run deploy |
wrangler deploy |
pnpm check |
svelte-check |
The website template
The website template adds a public site on top of the same structure.
src/routes/(site)/has the public routes: pages, a paginated blog and legal pages.src/lib/blocks/has one Svelte component per block, plusRenderBlocks.svelte, which maps each block'sblockTypeto its component.src/lib/image.tsandsrc/lib/Img.sveltebuild image URLs. See Images.src/kitcms.seed.tsholds example content. Run it withpnpm db:seed.- It also adds the
db:migrate:remoteanddb:seed:remotescripts.