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.
-
Load functions for data. A page gets its data from
loadin+page.server.tsfor private data or+page.tsfor public data. Components do not fetch first-render data on mount. -
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.
-
Forms work without JavaScript. Writes go through form actions that validate on the server and return
fail(400, ...)with the values and errors.use:enhanceadds the smooth version, and a Playwright test with JavaScript disabled proves the plain one. -
Server code stays on the server. Secrets come from
$env/static/privateor$env/dynamic/privateand server-only code lives in$lib/server. SvelteKit fails the build when the client imports them, and nobody works around it. -
Every request is authorized. The
handlehook inhooks.server.tsputs the user inevent.locals. Every serverloadand every action checks it; a layout check alone is not enough. -
Typed and checked. Components use Svelte 5 runes (
$state,$derived,$props) with typed props.svelte-checkruns in CI and any error fails the build.