derived in Svelte

From the Svelte cheat sheet ยท Runes (Svelte 5) ยท verified Jul 2026

$derived

Computed values from state

javascript
<script>
  let count = $state(0);
  
  // Simple derived
  const doubled = $derived(count * 2);
  
  // Object derived
  const stats = $derived({
    count,
    doubled: count * 2,
    isEven: count % 2 === 0
  });
</script>

<p>Count: {count}, Doubled: {doubled}</p>
๐Ÿ”„ Auto-updates when dependencies change
๐Ÿ“Š Perfect for calculated values and statistics
๐ŸŽฏ Replaces $: reactive statements from Svelte 4
โšก Cached and optimized automatically

More Svelte tasks

Back to the full Svelte cheat sheet