interface SseMessage
Since 0.1.0

A single SSE event payload.

Properties

readonly
optional
id: string

Unique event identifier — sent as id: field; enables Last-Event-ID resume.

readonly
optional
event: string

Event type name — sent as event: field.

readonly
data: JsonValue

Event data. A string is written literally (split on \n into multiple data: lines); any non-string is JSON.stringify-ed. undefined is forbidden — use {} or omit the message instead.

Typed JsonValue, so the compiler admits exactly what the encoder can write. A bigint makes JSON.stringify throw, and a function or symbol value makes it silently drop the key; both are refused here rather than at runtime, where the local delivery path swallows the failure per member and the backplane path throws out of publish.

Three things the type cannot catch: a circular structure throws at runtime; a named interface does not assign, because TypeScript grants implicit index signatures only to object-literal types (declare the payload with a type alias, or extend Record<string, JsonValue | undefined>); and NaN / Infinity / -Infinity reach the wire as null, because JSON.stringify normalizes them rather than failing.

readonly
optional
retry: number

Reconnection time in milliseconds — sent as retry: field.

Usage

import { type SseMessage } from "sse-plugin/src/index.ts";