Svelte · Middle · Question 58 of 75

What does $props.id() (Svelte 5.20+) generate?

<script>
  const uid = $props.id();
</script>

<label for="{uid}-email">Email</label>
<input id="{uid}-email" />

Explanation

Random ids generated with Math.random() would differ between server and client and break hydration.

Further reading

Problem with a question

Svelte · Middle · question 58

Test yourself

Take the Svelte · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz