Skip to content

🌐 Leggi in Italiano

Svelte 5 and runes: explicit reactivity

An overview of $state, $derived, $effect and $props, and how they change the way you write Svelte components.

Alessandro Manias Alessandro Manias Published on · 1 min read
Stylised rune symbols in orange

With Svelte 5 reactivity becomes explicit thanks to runes: special functions recognised by the compiler.

$state

<script>
	let count = $state(0);
</script>

<button onclick={() => count++}>Clicked {count} times</button>

$derived

Derived values are recalculated automatically when their dependencies change:

let doubled = $derived(count * 2);

$props

Props are declared with destructuring, default values included:

let { title, size = 48 } = $props();

Event handlers

on:click directives become plain attributes such as onclick. The same goes for onerror on images, used on this blog for the avatar fallback.

© 2026 Wordpress e PHP. Statically generated with SvelteKit.