Svelte and SvelteKit 5 · Template syntax
Show an async result
Render pending, success and error states of a promise.
{#await promise}
<p>Loading...</p>
{:then data}
<p>{data.title}</p>
{:catch error}
<p>Failed: {error.message}</p>
{/await}
Official Svelte and SvelteKit 5 documentation
More template syntax commands
- Show content conditionally
- Loop over a list
- Bind form inputs
- Handle events
- Toggle classes
- Reusable markup with snippets
All template syntax commands · Svelte and SvelteKit 5 cheatsheet