← All templates

Load functions for data, progressive enhancement, forms that work without JavaScript.

Constitution — SvelteKit app

Version 1.0.0 · Ratified 2026-11-10

These principles hold for every spec, plan and task of the project. A spec may add rules; it never weakens these.

  1. Load functions for data. A page gets its data from load in +page.server.ts for private data or +page.ts for public data. Components do not fetch first-render data on mount.

  2. Progressive enhancement. Every page is rendered on the server and is usable before hydration. JavaScript improves the page; it is never required to read it.

  3. Forms work without JavaScript. Writes go through form actions that validate on the server and return fail(400, ...) with the values and errors. use:enhance adds the smooth version, and a Playwright test with JavaScript disabled proves the plain one.

  4. Server code stays on the server. Secrets come from $env/static/private or $env/dynamic/private and server-only code lives in $lib/server. SvelteKit fails the build when the client imports them, and nobody works around it.

  5. Every request is authorized. The handle hook in hooks.server.ts puts the user in event.locals. Every server load and every action checks it; a layout check alone is not enough.

  6. Typed and checked. Components use Svelte 5 runes ($state, $derived, $props) with typed props. svelte-check runs in CI and any error fails the build.