AWS Astro streaming
Follows the Astro Streaming guide to create an app that streams HTML.
The responseMode in the @sst-community/astro-sst adapter
is set to enable streaming.
adapter: aws({ responseMode: "stream"})Now any components that return promises will be streamed.
---import type { Character } from "./character";
const friends: Character[] = await new Promise((resolve) => setTimeout(() => { setTimeout(() => { resolve( [ { name: "Patrick Star", image: "patrick.png" }, { name: "Sandy Cheeks", image: "sandy.png" }, { name: "Squidward Tentacles", image: "squidward.png" }, { name: "Mr. Krabs", image: "mr-krabs.png" }, ] ); }, 3000);}));---<div class="grid"> {friends.map((friend) => ( <div class="card"> <img class="img" src={friend.image} alt={friend.name} /> <p>{friend.name}</p> </div> ))}</div>You should see the friends section load after a 3 second delay.
Safari uses a different heuristic to determine when to stream data. You need to render enough initial HTML to trigger streaming. This is typically only a problem for demo apps.
There’s nothing to configure for streaming in the Astro component.
new sst.aws.Astro("MyWeb");View the full example.