Svelte · Senior · Question 16 of 75

How do you show a loading state with async Svelte?

<svelte:boundary>
  <Profile />
  {#snippet pending()}
    <Spinner />
  {/snippet}
</svelte:boundary>

Explanation

The pending snippet is shown only on the first load. Subsequent updates keep the old UI, and $effect.pending() reports how many promises are in flight.

Further reading

Problem with a question

Svelte · Senior · question 16

Test yourself

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

Take this quiz