serverpod-streams

Expose Stream-based Dart methods as real-time WebSocket endpoints in Serverpod.

3.2k|369|Updated May 22, 2021
One-click install
npx skills add https://github.com/serverpod/serverpod --skill serverpod-streams
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: serverpod-streams
Source: https://github.com/serverpod/serverpod/tree/main/packages/serverpod/skills/serverpod-streams
Command: npx skills add https://github.com/serverpod/serverpod --skill serverpod-streams

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Serverpod streaming removes the friction of turning server-side stream data into real-time, WebSocket-managed updates that clients can consume reliably.

Core Features & Use Cases

  • Stream endpoint parameters and return values: Define Dart methods that accept Stream<T> or return Stream<T> to get WebSocket-managed client stubs.
  • Session and lifecycle management: Keeps sessions alive for return streams until the stream completes or is cancelled, and closes streams on WebSocket disconnect.
  • Serializable types and error propagation: Ensures streamed item types are serializable and propagates serializable exceptions to the client via onError.

Quick Start

Create an endpoint method that returns or consumes Stream<T> with serializable types, then run serverpod generate to produce the client stubs and start listening to the resulting stream.

Frequently Asked Questions about serverpod-streams

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build real-time WebSocket streaming APIs in Dart?

You build real-time WebSocket streaming APIs by defining Dart endpoint methods that accept or return Stream<T> with serializable types, then running serverpod generate to produce the client stubs for consumption.

How does Serverpod handle WebSocket session lifecycle for return streams?

WebSocket session lifecycle management keeps sessions alive for return streams until the stream completes or is cancelled, and automatically closes streams on WebSocket disconnect.

How are streaming errors propagated to the client over WebSockets?

Streaming errors are propagated to the client over WebSockets by throwing serializable exceptions, which are delivered through the stream's onError callback for predictable error handling.

Do I need serializable types for Serverpod stream endpoints?

Yes, you need serializable types for Serverpod stream endpoints because both the streamed item types and any exceptions propagated via onError must be serializable to traverse the WebSocket boundary.

What are the limitations of using Dart streams for real-time server-to-client push?

A key limitation is that all streamed item types and exceptions must be serializable, and streams are constrained by WebSocket session lifecycle behavior, closing automatically on disconnect.