Svelte and SvelteKit 5 · Runes (reactivity)

Component skeleton

A single-file component with state, markup and scoped styles.

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

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

<style>
  button { font-weight: bold; }
</style>

Official Svelte and SvelteKit 5 documentation

More runes (reactivity) commands

All runes (reactivity) commands · Svelte and SvelteKit 5 cheatsheet

Was this page helpful?