event-stream

The library under useEventStream: an incremental SSE parser and a fetch-based connection with resume and backoff, for code outside React.

const { close } = connectEventStream<Progress>("/api/tasks/7/events", {  events: ["progress"],  onEvent: (p) => render(p),  onState: (s) => setStatus(s),});

Installation

Once per app, set up Aedis UI. The CLI verifies the signed release before writing anything and pins every dependency:

npx @aedis/cli@0.1.0 init

Import the theme once in your global CSS, after Tailwind:

app/globals.css
@import "tailwindcss";@import "./styles/aedis-theme.css";

Then add the component:

npx @aedis/cli@0.1.0 add event-stream# pnpm dlx @aedis/cli@0.1.0 add event-stream · yarn dlx @aedis/cli@0.1.0 add event-stream · bunx @aedis/cli@0.1.0 add event-stream

Props

PropTypeDefaultDescription
connectEventStream(path, options){ close }—Same options as useEventStream plus signal and onState.
createSseParser({ onEvent, onRetry?, maxEventBytes? }){ push(text), end() }—Feed decoded text; chunking never changes the events.
assertStreamPath(path)void—Throws for another origin or a token in the query string.

Security

  • Same rules as useEventStream.