What problem does it solve?
Building realtime features like WebSockets, Server-Sent Events, and cross-service event fan-out in Litestar requires handling authentication, backend selection, typed event contracts, and cross-process publishing logic from scratch, leading to inconsistent implementations and avoidable bugs. This Skill provides opinionated, production-ready patterns for every layer of the Litestar realtime stack, eliminating boilerplate and ensuring consistency with Litestar best practices.
Core Features & Use Cases
- WebSocket & SSE Handler Patterns: Pre-built templates for connection lifecycle management, multi-tenant authentication guards, and request-scoped dependency injection for realtime endpoints.
- Channels Plugin Configuration: Ready-to-use setup for all supported backends (in-memory, Redis, PostgreSQL LISTEN/NOTIFY, SQLSpec) selected based on your existing stack dependencies to avoid unnecessary infrastructure.
- Typed Event Contracts: Canonical
RealtimeEvent envelope, scope-based access control tables, and channel naming factories for consistent, type-safe pub/sub messaging across services.
- Cross-Process Publishing: Patterns for broadcasting events from SAQ workers, CLI scripts, and database observers to connected realtime clients, with graceful handling of uninitialized channel backends.
- Use Case Example: Build a workspace event stream that authenticates users via JWT query parameters, restricts access to workspace members, and broadcasts ETL job status updates from background workers to all connected clients in real time.
Quick Start
Use the litestar-realtime skill to implement an authenticated WebSocket endpoint that streams workspace-specific events to authorized users with typed payloads and proper disconnect handling.