0Pricing
Sveltejs Academy · Lesson

$state: Fine-Grained Reactivity

Declare reactive state with the $state rune for granular DOM updates.

Declare State

Use $state(initial) to declare a reactive variable.

let count = $state(0);

Reassign Normally

Update with regular assignment. Svelte re-renders dependent UI.

count = count + 1;

All lessons in this course

  1. Why Runes: Moving Beyond the Compiler Magic
  2. $state: Fine-Grained Reactivity
  3. $derived: Declarative Computed Values
  4. $effect: Side Effects
← Back to Sveltejs Academy