Skip to content

feat(sveltekit): add Lambda response streaming support#6674

Open
ekaya97 wants to merge 1 commit intoanomalyco:devfrom
ekaya97:feat/sveltekit-streaming
Open

feat(sveltekit): add Lambda response streaming support#6674
ekaya97 wants to merge 1 commit intoanomalyco:devfrom
ekaya97:feat/sveltekit-streaming

Conversation

@ekaya97
Copy link
Copy Markdown
Contributor

@ekaya97 ekaya97 commented Mar 31, 2026

Summary

  • Adds Lambda response streaming for sst.aws.SvelteKit, matching the existing support in React and Remix
  • Ships a custom streaming handler (platform/functions/sveltekit-server/server.mjs) that SST copies into the build output at deploy time, replacing the buffered handler from svelte-kit-sst
  • Sets streaming: true in the SvelteKit component's build plan so the Lambda function URL is configured for streaming mode

How it works

  1. User's SvelteKit app builds normally with the svelte-kit-sst adapter (no adapter changes needed)
  2. During buildPlan(), SST copies the streaming handler into the server output directory alongside the adapter's Server, manifest, and prerendered file list
  3. The handler uses awslambda.streamifyResponse() to stream responses — the HTML shell and instant data arrive immediately, while deferred promises resolve progressively

Demo

The example app includes a /streaming route that demonstrates progressive streaming with deferred data:

sveltekitstreaming.mp4

Test plan

  • E2E: Deployed examples/aws-svelte-kit — verified GET /, GET /streaming, POST, HEAD, 404, static assets, query strings all work correctly
  • Verified x-amzn-remapped-content-length header present (Lambda streaming signature)
  • Verified /streaming route streams instant data immediately, then resolves 2s and 4s deferred promises progressively

SvelteKit on SST now uses Lambda response streaming instead of buffered
responses. This ships a custom streaming handler (like React and Remix
already have) that replaces the buffered handler from svelte-kit-sst at
deploy time. Includes a /streaming demo route in the example app.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant