Svelte 5 Overview
Svelte 5 introduces a new reactivity system called “Runes.” It achieves more explicit and predictable reactivity with improved TypeScript compatibility.
What are Runes
Runes are special functions that start with $. The compiler recognizes these and transforms them into reactive code.
$state - Reactive State
Object State
{user.name} is {user.age} years old
$derived - Derived Values
Define values computed from other state.
Area: {area}
Perimeter: {perimeter}
Complex Derivations
$effect - Side Effects
Execute side effects in response to state changes.
DOM Operations
$props - Component Properties
{name} is {age} years old
console.log(newAge)} />
$bindable - Two-Way Binding
Value: {text}
Event Handling Changes
TypeScript Support
Migration Guide
# Auto-migration tool
npx sv migrate svelte-5
Gradual Migration
Svelte 5 maintains compatibility with legacy syntax, allowing gradual migration.
Performance
Benchmark (1000 element list update):
- Svelte 4: 12ms
- Svelte 5: 5ms (58% faster)
Bundle Size:
- Svelte 4 runtime: 18KB
- Svelte 5 runtime: 22KB (slightly increased due to new features)
Summary
Svelte 5’s Runes provide more explicit and predictable reactivity. With $state, $derived, and $effect, state management becomes intuitive, and TypeScript integration is improved.
← Back to list