Svelte · Middle · Question 31 of 75

How do you build a Svelte component as a custom element?

<svelte:options customElement="my-counter" />

Explanation

Inside, $host() gives access to the host element, e.g. to dispatch events.

Further reading

Problem with a question

Svelte · Middle · question 31

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