Question · Svelte and SvelteKit course · Module 1: Introduction to Svelte

Variable Reactivity

What makes a variable reactive in Svelte 5?

Answer options

  • You need to use a special useState function
  • Declaring it with the $state rune, e.g. let count = $state(0)
  • Every let variable is automatically reactive
  • You need to use Vue.ref()
Show the answer

Correct answer:

  • Declaring it with the $state rune, e.g. let count = $state(0)