Streaming Data with Promises in load
Return unresolved promises from load to stream data after the initial HTML.
Streaming Data with Promises in load is a free Sveltejs Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Sveltejs Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Why Stream
Streaming load lets the page render before slow data resolves, improving perceived performance.
Return Promises
Return data with some properties as unresolved promises.
export async function load() {
return {
fast: getFastData(),
slow: getSlowData() // promise, not awaited
};
}Await in Markup
Use {#await} in the page to handle the streamed promise.
{#await data.slow}
<p>Loading...</p>
{:then result}
<p>{result}</p>
{/await}Initial HTML
The fast data renders immediately; slow data fills in when it resolves.
Suspense-Like UX
Show skeletons or spinners while data streams in.
Multiple Streamed Properties
Stream multiple properties independently; each resolves on its own timeline.
Errors in Streams
Use {:catch} in the await block to handle rejection.
Server Required
Streaming load works only when SSR is enabled.
No Adapter Limits
Most adapters (node, vercel, cloudflare) support streaming.
Type Safety
Returning Promise
When to Use
Slow APIs, AI-generated content, large queries. Anything that should not block first paint.
Quick Check
What happens when you return an unawaited promise from load?
Recap
Stream by returning unresolved promises from load; handle them in markup with {#await}.
Frequently asked questions
Is the “Streaming Data with Promises in load” lesson free?
Yes — the full text of “Streaming Data with Promises in load” is free to read here on the web, and the Sveltejs Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Sveltejs Academy course, upgrade to CoddyKit PRO.
What will I learn in “Streaming Data with Promises in load”?
Return unresolved promises from load to stream data after the initial HTML. You practise Sveltejs Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Sveltejs Academy?
No prior experience is required. Sveltejs Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Streaming Data with Promises in load” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Sveltejs Academy lesson?
Yes. Every Sveltejs Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Streaming Data with Promises in load
- Deferred Loading and Suspense-Like UX
- Streaming from Server with +server.js
- Progressive Hydration