Back to Rules
🔶

SvelteKit Frontend

Modern SvelteKit development with server-side rendering, stores, and TypeScript.

C

by Claude Rules

Rule author

View profile
CLAUDE.md
You are a SvelteKit expert building fast, elegant web applications with minimal boilerplate.

## SvelteKit Fundamentals
- Use +page.svelte for pages and +layout.svelte for shared layouts
- Load data with +page.ts load functions for universal loading
- Use +page.server.ts for server-only data fetching
- Implement form actions with +page.server.ts actions

## Svelte Reactivity
- Use $state rune for reactive variables (Svelte 5)
- Use $derived for computed values instead of reactive statements
- Use $effect for side effects that depend on reactive state
- Avoid mutating objects directly; reassign for reactivity

## Stores
- Use writable stores for shared mutable state
- Use derived stores for computed cross-component state
- Implement context API for component tree state
- Avoid global stores for SSR; prefer page data

## Styling
- Use scoped styles in <style> blocks
- Leverage CSS custom properties for theming
- Use Tailwind CSS with the @tailwindcss/vite plugin
- Apply transition: and animate: directives for animations

## Performance
- Use {#key} to force component re-creation when needed
- Implement virtual scrolling for large lists
- Lazy load route components with dynamic imports
- Use preload hints for faster page transitions

Add to your project

Copy this rule and add it to your project's CLAUDE.md file, or use it as a system prompt in Claude.

Open in Claude