Server-Sent Events (SSE)
Real-time server-to-client event streaming and consumption for building AI agents, live dashboards, and real-time notifications
🌐 What are Server-Sent Events?
📋 Table of Contents
🔄 SSE Creation vs Consumption
SSE Creation - SSE() BIF
SSE() BIFSSE Consumption - http() BIF / bx:http Component
http() BIF / bx:http Component📋 SSE() BIF - Creating Streams
Syntax
Parameters
Parameter
Type
Required
Default
Description
Emitter Methods
send( data, [event], [id] )
comment( text )
close()
isClosed()
💡 Usage Examples
Basic Synchronous Streaming
AI Streaming with Async Execution
Cross-Origin Streaming
Live Dashboard Updates
Progress Tracking
Log Streaming
Real-Time Notifications
🎨 Client-Side JavaScript
Basic EventSource Usage
AI Streaming Example
Dashboard Updates Example
⚙️ Implementation Features
Automatic First-Byte Flush
Large Data Chunking
Multi-Line Data Support
Client Disconnect Detection
Proxy/Nginx Compatibility
Keep-Alive Support
🎯 Best Practices
🔒 Security Considerations
Authentication
Authorization
CORS Configuration
Rate Limiting
🔗 Related Resources
📚 Additional Examples
Multi-Channel Chat Streaming
Stock Price Updates
📥 SSE Consumption - Connecting to Remote Streams
Why Consume SSE?
Basic SSE Consumption
Using the http() BIF
http() BIFUsing the bx:http Component
bx:http ComponentSSE Event Structure
Callback Parameters
Parameter
Type
Description
Real-World SSE Consumption Examples
OpenAI Streaming Chat
Claude AI Streaming
Real-Time Stock Quotes
Server Monitoring Feed
GitHub Events Stream
Advanced SSE Consumption Patterns
Reconnection with Last Event ID
Multiple Event Types
Timeout and Error Handling
SSE Consumption Best Practices
🎯 Summary
Last updated
Was this helpful?
