svelte-runes
Provides a quick start guide for Svelte Runes, covering core concepts like $props, $bindable, $derived, $effect, and $state.
npx skills add spences10/svelte-skills-kit --skill svelte-runesBefore / After Comparison
1 组In Svelte 4 or earlier versions, managing component state and reactive logic required relying on `$:` declarations or custom stores. For complex state flows, the code could become verbose and difficult to understand.
With Svelte 5's `Runes` (e.g., `$state()`, `$bindable()`, `$derived()`, `$effect()`), reactive state can be managed in a more intuitive and fine-grained manner. This simplifies state management code, improves development efficiency, and makes component logic clearer.
description SKILL.md
svelte-runes
Svelte Runes
Quick Start
Which rune? Props: $props() | Bindable: $bindable() |
Computed: $derived() | Side effect: $effect() | State: $state()
Key rules: Runes are top-level only. $derived can be overridden
(use const for read-only). Don't mix Svelte 4/5 syntax.
Objects/arrays are deeply reactive by default.
Example
<script>
let count = $state(0); // Mutable state
const doubled = $derived(count * 2); // Computed (const = read-only)
$effect(() => {
console.log(`Count is ${count}`); // Side effect
});
</script>
<button onclick={() => count++}>
{count} (doubled: {doubled})
</button>
Reference Files
-
reactivity-patterns.md - When to use each rune
-
migration-gotchas.md - Svelte 4→5 translation
-
component-api.md - $props, $bindable patterns
-
snippets-vs-slots.md - New snippet syntax
-
common-mistakes.md - Anti-patterns with fixes
For @attach and other template directives, see the
svelte-template-directives skill.
Notes
-
Use
onclicknoton:click,{@render children()}in layouts -
$derivedcan be reassigned (5.25+) - useconstfor read-only -
Use
createContextoversetContext/getContextfor type safety -
Use
$inspect.traceto debug reactivity issues -
Last verified: 2026-03-12
Weekly Installs241Repositoryspences10/svelt…ills-kitGitHub Stars52First SeenJan 20, 2026Security AuditsGen Agent Trust HubPassSocketPassSnykPassInstalled onopencode195gemini-cli174codex160claude-code158github-copilot156cursor140
forumUser Reviews (0)
Write a Review
No reviews yet
Statistics
User Rating
Rate this Skill