Guides Svelte and SvelteKit development including reactive components, stores, transitions, lifecycle hooks, SSR, file-based routing, and deployment. Use when the user needs to build Svelte components, create SvelteKit applications, implement reactivity patterns, or configure Svelte with Vite.
Use this skill whenever the user wants to:
npm create svelte@latest my-app for SvelteKit or Vite+Svelte.svelte files with script, markup, and style blocks$: reactive declarations and Svelte storesnpm run build with adapter-auto, adapter-node, or adapter-static<script>
let count = 0;
$: doubled = count * 2;
$: if (count > 10) console.log('Count is high!');
function increment() {
count += 1;
}
</script>
<button on:click={increment}>
Clicked {count} {count === 1 ? 'time' : 'times'}
</button>
<p>Doubled: {doubled}</p>
<style>
button {
padding: 0.5rem 1rem;
border-radius: 4px;
background: #ff3e00;
color: white;
border: none;
cursor: pointer;
}
</style>
// stores.js
import { writable, derived } from 'svelte/store';
export const todos = writable([]);
export const completedCount = derived(todos, $todos =>
$todos.filter(t => t.done).length
);
<script>
import { todos, completedCount } from './stores.js';
let newTodo = '';
function addTodo() {
todos.update(t => [...t, { text: newTodo, done: false }]);
newTodo = '';
}
</script>
<input bind:value={newTodo} />
<button on:click={addTodo}>Add</button>
<p>Completed: {$completedCount}</p>
$: blocks; use them for derived values.svelte file should handle one concern<script lang="ts"> for type safety in components+page.server.ts for server-side data loading, form actions for mutationssvelte, SvelteKit, reactive, component, store, transition, SSR, Vite, 响应式, 编译时, file-based routing