Best use case
sse is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Server-Sent Events one-way real-time. Use for live updates.
Teams using sse should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/sse/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How sse Compares
| Feature / Agent | sse | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Server-Sent Events one-way real-time. Use for live updates.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Server-Sent Events (SSE)
SSE allow a web page to get updates from a server. Unlike WebSockets, SSEs are **unidirectional** (Server -> Client) and use standard HTTP.
## When to Use
- **Live Feeds**: News tickers, Sport scores, Stock prices.
- **Progress Updates**: "Processing Import: 45%...", Logging streams.
- **Notifications**: In-app alerts where the user doesn't need to reply instantly via the same channel.
- **Replacement for Polling**: More efficient than asking "Are we there yet?" every second.
## Quick Start
```javascript
// Client
const evtSource = new EventSource("/api/events");
evtSource.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log("Update:", data);
};
```
```javascript
// Server (Express)
app.get("/api/events", (req, res) => {
// Headers to keep connection open
res.setHeader("Content-Type", "text/event-stream");
res.setHeader("Cache-Control", "no-cache");
res.setHeader("Connection", "keep-alive");
setInterval(() => {
// Format: "data: <payload>\n\n"
res.write(`data: ${JSON.stringify({ time: new Date() })}\n\n`);
}, 1000);
});
```
## Core Concepts
### Event Stream Format
Plain text. Fields: `event`, `data`, `id`, `retry`.
```
event: update
data: {"value": 42}
data: This is a default message
```
### Auto-Reconnection
Browsers automatically try to reconnect if the connection drops. The server can send a `retry: 5000` field to control the delay.
## Common Patterns
### Connection Limit
Browsers (HTTP/1.1) limit concurrent connections (usually 6) per domain. Using HTTP/2 solves this (Multi-plexing).
## Best Practices
**Do**:
- Use **HTTP/2** to avoid connection limits.
- Send **Hearbeats** (comments `: ping`) to prevent proxies from killing idle connections.
- Use the `Last-Event-ID` header to resume streams after incorrect.
**Don't**:
- Don't use for Gaming/Chat (Latency and bidirectionality needs WebSockets).
- Don't send huge binary blobs (It's text-based).
## Troubleshooting
| Error | Cause | Solution |
| :------------------ | :-------------------------------- | :------------------------------------------------- |
| `Buffered Response` | Nginx/Proxy buffering the stream. | Disable proxy buffering (`X-Accel-Buffering: no`). |
| `Cors Error` | Standard CORS rules apply. | Configure Access-Control headers. |
## References
- [MDN Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events)Related Skills
template
Expert [skill-name] assistance covering [feature 1], [feature 2], and [feature 3]. Use when [working with X], [debugging Y], or [implementing Z].
zsh
Zsh shell with oh-my-zsh. Use for terminal shell.
zed
Zed high-performance collaborative editor. Use for fast editing.
xcode
Xcode Apple development IDE with simulators. Use for iOS/macOS development.
webstorm
WebStorm JavaScript IDE with debugging. Use for web development.
webpack
Webpack module bundler with loaders and plugins. Use for bundling.
warp
Warp modern terminal with AI. Use for terminal work.
vscode
Visual Studio Code editor with extensions and debugging. Use for code editing.
vite
Vite fast build tool with HMR. Use for modern frontend builds.
visual-studio
Visual Studio IDE for Windows with debugging and profiling. Use for .NET development.
vim
Vim text editor with motions, macros, and plugins. Use for terminal editing.
turbopack
Turbopack Rust-powered bundler. Use for fast builds.