# SSEStreamingApi

**Kind:** Class

**Source:** [`src/helper/streaming/sse.ts`](https://github.com/honojs/hono/blob/main/src/helper/streaming/sse.ts#L13)

**Part of:** [Helper](subsystem-src-helper)

`SSEStreamingApi` provides the Server-Sent Events streaming helper for the application. Its `writeSSE()` method writes data through the SSE response flow so connected clients can receive streamed updates.

**Extends:** `StreamingApi`

## Methods

| Method | Signature | Returns |
|---|---|---|
| `writeSSE` | `writeSSE(message: SSEMessage)` | `void` |

## Where it refuses work

- `SSEStreamingApi` stops the work with `Error` when `value && /[\r\n]/.test(value)`.

## Diagram

```mermaid
graph LR
  A[Application event] --> B[SSEStreamingApi]
  B --> C[writeSSE()]
  C --> D[SSE response stream]
  D --> E[Connected client]
```

## Usage

```ts
import { SSEStreamingApi } from './helper/streaming/sse';

const sseStreamingApi = new SSEStreamingApi();

sseStreamingApi.writeSSE();
```

## AI Coding Instructions

- Keep SSE-specific output handling inside `SSEStreamingApi`.
- Call `writeSSE()` from code that already owns the active SSE response flow.
- Preserve the event formatting expected by connected SSE clients when changing `writeSSE()`.
- Handle closed or unavailable response streams at the integration point.
