svelte5-runes

Guide Svelte 5 rune usage for reactive state, props, and side effects.

6|Updated Jul 7, 2017
One-click install
npx skills add https://github.com/Seeker1911/dotfiles --skill svelte5-runes-seeker1911
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: svelte5-runes
Source: https://github.com/Seeker1911/dotfiles/tree/main/agents/skills/svelte5-runes
Command: npx skills add https://github.com/Seeker1911/dotfiles --skill svelte5-runes-seeker1911

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Svelte 5 introduces a new reactivity system (runes) that can be confusing, leading to common mistakes when migrating from Svelte 4 or when managing reactive state, props, and side effects. This Skill provides expert guidance to prevent these pitfalls, ensuring your Svelte 5 applications are robust and performant.

Core Features & Use Cases

  • Reactive State Management: Get clear guidance on $state(), $derived(), and $effect() for managing component state, computed values, and side effects.
  • Component API Mastery: Learn best practices for $props() and $bindable() to define and use component properties, including seamless two-way binding.
  • Svelte 4 to 5 Migration: Effortlessly translate Svelte 4 reactive statements and event handlers to the new Svelte 5 rune-based syntax, avoiding common migration gotchas.
  • Use Case: When you're building a new Svelte 5 component and need to manage local state, computed values, and side effects, or when migrating an existing Svelte 4 component to the new runes system, this Skill ensures you apply the correct patterns.

Quick Start

Help me refactor my Svelte 4 component to use Svelte 5 runes for state management and props. I have a count variable and a doubled computed value, and an on:click event handler.

Frequently Asked Questions about svelte5-runes

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage reactive state in Svelte 5 using runes?

Svelte 5 runes manage reactive state through `$state()` for mutable values, `$derived()` for computed values, and `$effect()` for side effects. Declare runes at the top level of your component script to ensure reactivity works correctly and integrates seamlessly with Svelte 5's compilation model.

What's the best way to migrate a Svelte 4 component to Svelte 5 runes?

Replace Svelte 4 reactive declarations and event handlers with Svelte 5 runes: convert `let` to `$state()`, reactive statements to `$derived()`, and `on:` handlers to direct function calls. Avoid mixing Svelte 4 and 5 syntax in the same component to prevent unexpected behavior.

How do I define and bind component props in Svelte 5?

Use `$props()` to declare component properties and `$bindable()` for two-way binding. These runes replace Svelte 4's export syntax and provide explicit, type-safe prop definitions with built-in reactivity.

Can I use two-way binding with Svelte 5 runes?

Yes, two-way binding is enabled through the `$bindable()` rune on component props. This allows parent components to bind directly to child state, replacing Svelte 4's bind: directive pattern with a clearer, rune-based approach.

What are common mistakes when using Svelte 5 runes?

Common pitfalls include declaring runes inside conditionals or functions instead of at top level, mixing Svelte 4 and 5 reactivity syntax, and misusing `$derived()` for side effects instead of `$effect()`. Top-level declarations ensure deterministic behavior and predictable reactivity.

Does Svelte 5 rune syntax work with existing Svelte 4 event handlers?

No, Svelte 4 `on:` directives are not compatible with Svelte 5 runes. Migrate event handlers to direct function calls on DOM elements or use component callbacks passed through `$props()` for parent-child communication.