Svelte 5.36 Lets Developers Use Await Directly in Components, Cutting Boilerplate
Since Svelte 5.36, developers can use the await keyword directly in component markup, reactive declarations, and script blocks, reducing the need for manual loading flags and error states. Svelte holds UI updates until all awaited promises resolve, preventing partially updated or 'torn' interfaces where some values are new and others are stale. Multiple independent await expressions in markup run in parallel, though sequential awaits inside scripts still execute top-to-bottom, and Svelte will issue a warning when this creates a performance waterfall. A new boundary system with a pending snippet handles placeholder UI, while $effect.pending() tracks outstanding promises for granular loading indicators. The feature is currently experimental, meaning the API details of await handling and related utilities may change without a major version bump.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in