# Svelte 5 Runes Reference ## Table of Contents - [$state - Reactive State](#state---reactive-state) - [$derived - Computed Values](#derived---computed-values) - [$effect - Side Effects](#effect---side-effects) - [$props - Component Props](#props---component-props) - [$bindable - Two-Way Binding](#bindable---two-way-binding) - [$inspect - Debugging](#inspect---debugging) --- ## $state - Reactive State In Svelte 5, plain `let` declarations are no longer automatically reactive. Use `$state()` for reactive state. ### Basic Usage ```svelte ``` ### Object and Array State Objects and arrays are deeply reactive by default: ```svelte ``` ### Class State ```svelte ``` ### Raw State (Opt-out of Deep Reactivity) ```svelte ``` --- ## $derived - Computed Values Replaces `$:` reactive statements for computed values. ### Basic Usage ```svelte ``` ### Complex Derivations with $derived.by ```svelte ``` ### Deriving from Props ```svelte ``` ### $derived vs $effect Use `$derived` for computing values, `$effect` for side effects: ```svelte ``` --- ## $effect - Side Effects Runs code when component mounts and when dependencies change. Requires cleanup for subscriptions. ### Basic Effect with Cleanup ```svelte ``` ### DOM Event Listeners ```svelte ``` ### External Subscriptions ```svelte ``` ### $effect.pre for Pre-DOM Updates ```svelte ``` ### Untracked Dependencies ```svelte ``` --- ## $props - Component Props Replaces `export let` for declaring component props. ### Basic Usage ```svelte ``` ### Rest Props Pattern ```svelte
{@render children?.()}
``` ### Renaming Reserved Words ```svelte ``` ### TypeScript Props ```svelte ``` ### Props with Children ```svelte

{title}

{@render children()}
{#if footer}{/if}
``` --- ## $bindable - Two-Way Binding Props must be explicitly marked with `$bindable()` to support `bind:`. ### Basic Usage ```svelte ``` ### Bindable with Default Value ```svelte ``` ### Multiple Bindable Props ```svelte ``` ### TypeScript with Bindable ```svelte ``` --- ## $inspect - Debugging Development-only debugging that logs values when they change. Stripped in production. ### Basic Usage ```svelte ``` ### Multiple Values ```svelte ``` ### Custom Logging with $inspect.with ```svelte ``` ### Debugging with Breakpoints ```svelte ```