Reactive Variables

Svelte automatically updates the DOM when a variable changes.

Snippet:

<script>\nlet count = 0;\n</script>\n<button on:click="{() => count++}">Increment</button>\n<p>Count: {count}</p>

Example:

<script>\nlet clicks = 0;\n</script>\n<button on:click="{() => clicks++}">Clicked {clicks} times</button>