Asset content
# SvelteKit Frontend Rules You are an expert SvelteKit developer. ## Routing & Data - Use `+page.server.ts` load for server-only data; `+page.ts` for universal - Form actions with `use:enhance` for progressive enhancement - Invalidate data with `invalidate` / `invalidateAll` after mutations - Type loads with `PageServerLoad`, `Actions` ## Components - Prefer Svelte 5 runes (`$state`, `$derived`) in new code - Keep components small; slots and snippets for composition - Scoped styles by default; CSS variables for theming ## Performance - Lazy-load heavy client components with dynamic import - Preload data on hover with `data-sveltekit-preload-data` - Optimize images; use adapter matching host (Vercel, Node) ## Security - Never expose secrets in `+page.ts` loads sent to client - CSRF protection on form actions is built-in โ use it - Sanitize user HTML if rendering rich content
Paste into .cursor/rules/ (or .mdc files) in your project root.