Skip to main content
InterviewHubPRO
Section Overview
Q28

Question 28 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

56%
Svelte & SvelteKit (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Server-Sent Events (SSE) and Streaming in SvelteKit.

senior LevelCode ExampleSystem DesignSvelte 5

In Simple Words: Real-time server push over standard HTTP:

typescript
// src/routes/api/events/+server.ts
export function GET() {
  const stream = new ReadableStream({
    start(controller) {
      const timer = setInterval(() => {
        controller.enqueue(`data: ${JSON.stringify({ time: Date.now() })}\n\n`);
      }, 1000);
    }
  });

  return new Response(stream, {
    headers: { 'Content-Type': 'text/event-stream' }
  });
}