[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-83898":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":16,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":16,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":19,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":38,"readmeContent":39,"aiSummary":10,"trendingCount":15,"starSnapshotCount":15,"syncStatus":16,"lastSyncTime":40,"discoverSource":41},83898,"sse-runtime","FlameFront-end\u002Fsse-runtime","FlameFront-end","Everything the native EventSource API is missing — typed events, auth headers, reconnect, and single-tab coordination.","https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@flamefrontend\u002Fsse-runtime-core",null,"TypeScript",22,1,60,0,2,0.9,"MIT License",false,"main",true,[23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"broadcast-channel","devtools","eventsource","frontend","npm-package","open-source","react","react-hooks","realtime","reconnect","server-sent-events","sse","typescript","web-locks","websocket-alternative","2026-06-12 02:04:36","# sse-runtime\n\n**Production-grade Server-Sent Events for the browser — typed, resilient, and tab-aware.**\n\nThe native `EventSource` can't send an `Authorization` header, gives you untyped\n`message` blobs, reconnects with no control, and opens a fresh connection in\nevery tab. `sse-runtime` replaces it with a `fetch`-based client that handles the\nhard parts of long-lived SSE streams so your app code stays small.\n\n```ts\n\u002F\u002F Native EventSource — no headers, no types, one connection per tab\nconst es = new EventSource(\"\u002Fapi\u002Fchats\u002F123\u002Fstream\");\nes.onmessage = (e) => console.log(JSON.parse(e.data)); \u002F\u002F any\n\n\u002F\u002F sse-runtime — auth headers, typed events, shared across tabs\nconst client = createSSEClient\u003CChatEvents>({\n  key: [\"chat\", \"123\"],\n  url: \"\u002Fapi\u002Fchats\u002F123\u002Fstream\",\n  headers: { Authorization: `Bearer ${token}` },\n  events: { message: (m) => console.log(m.text) }, \u002F\u002F typed\n  coordination: { enabled: true, mode: \"single-tab\" }\n});\n```\n\n## Features\n\n- **Typed events** — declare an event map once; handlers and payloads are fully inferred.\n- **Auth that works** — static or async `headers`, plus a `401` refresh-and-retry hook.\n- **Resilient reconnects** — jittered exponential backoff, `maxRetries` cap, honors server `retry:` field.\n- **Custom retry policy** — `shouldRetry` predicate and `getDelay` for per-error classification (e.g. terminal 4xx, special handling for 429).\n- **Open timeout** — abort the HTTP connection attempt if the server takes too long to respond.\n- **Connection readiness** — `ensureOpen({ timeout })` resolves when the stream is ready; safe to call before any action that depends on an active connection.\n- **Seamless resumption** — tracks `Last-Event-ID` and resumes the stream on reconnect.\n- **Single-tab coordination** — one real connection per browser, shared to every tab via Web Locks + `BroadcastChannel`, with transparent failover.\n- **Observable state** — `idle \u002F connecting \u002F open \u002F reconnecting \u002F error \u002F closed` plus structured errors.\n- **Rich diagnostics** — `onOpen`, `onDisconnect`, `onRawEvent`, `onParseError`, and more for logging and debugging.\n- **Devtools** — drop-in panel to inspect live connections, event logs, and status while developing.\n- **Zero runtime dependencies** — framework-agnostic core; a thin React hook on top.\n\n## Packages\n\n| Package                                                            | Description                                           |\n| ------------------------------------------------------------------ | ----------------------------------------------------- |\n| [`@flamefrontend\u002Fsse-runtime-core`](packages\u002Fcore)                 | Framework-agnostic SSE runtime.                       |\n| [`@flamefrontend\u002Fsse-runtime-react`](packages\u002Freact)               | `useSSE` hook built on top of core.                   |\n| [`@flamefrontend\u002Fsse-runtime-react-native`](packages\u002Freact-native) | React Native hooks and lifecycle helpers.             |\n| [`@flamefrontend\u002Fsse-runtime-devtools`](packages\u002Fdevtools)         | Devtools panel to inspect connections, events, state. |\n\n## Install\n\n```bash\n# React hook\nnpm install @flamefrontend\u002Fsse-runtime-react\n\n# Framework-agnostic core\nnpm install @flamefrontend\u002Fsse-runtime-core\n\n# Devtools panel (optional, dev only)\nnpm install @flamefrontend\u002Fsse-runtime-devtools\n```\n\n> Works with any package manager — swap `npm install` for `pnpm add` or `yarn add`.\n\n## Quick Start (React)\n\n```tsx\nimport { useSSE } from \"@flamefrontend\u002Fsse-runtime-react\";\n\ntype ChatEvents = {\n  message: { id: string; text: string };\n  done: { chatId: string };\n};\n\nexport function ChatStream({ chatId, token }: { chatId: string; token: string }) {\n  const connection = useSSE\u003CChatEvents>({\n    key: [\"chat\", chatId],\n    url: `\u002Fapi\u002Fchats\u002F${chatId}\u002Fstream`,\n    enabled: Boolean(chatId),\n    headers: { Authorization: `Bearer ${token}` },\n    events: {\n      message: (message) => console.log(message.text),\n      done: (done) => console.log(done.chatId)\n    }\n  });\n\n  return (\n    \u003Csection>\n      \u003Cp>Status: {connection.status}\u003C\u002Fp>\n      {connection.error ? \u003Cp>Error: {connection.error.message}\u003C\u002Fp> : null}\n    \u003C\u002Fsection>\n  );\n}\n```\n\nThe hook connects on mount, disconnects on unmount, and keeps event handlers and\ndynamic options fresh across renders without tearing down the connection.\n\n## Documentation\n\n- [Getting Started](docs\u002Fgetting-started.md) — install, first stream, server format.\n- [API Reference](docs\u002Fapi-reference.md) — every option, method, and type.\n- [Recipes](docs\u002Frecipes.md) — auth refresh, resumption, multi-tab coordination.\n- [Troubleshooting](docs\u002Ftroubleshooting.md) — common pitfalls and fixes.\n- Package guides: [core](packages\u002Fcore\u002FREADME.md) · [react](packages\u002Freact\u002FREADME.md) · [react-native](packages\u002Freact-native\u002FREADME.md) · [devtools](packages\u002Fdevtools\u002FREADME.md)\n\n## Browser Support\n\nThe default transport uses `fetch`, `ReadableStream`, `AbortController`, and\n`TextDecoder`. Single-tab coordination additionally uses `BroadcastChannel` and\nthe Web Locks API, falling back to an independent per-tab connection when either\nis unavailable.\n\n## Development\n\n```bash\npnpm install        # install workspace dependencies\npnpm build          # build all packages\npnpm -r typecheck   # typecheck every package\npnpm test           # run the test suite\npnpm lint           # eslint\npnpm dev            # run the react-chat-demo\n```\n\n## License\n\nMIT\n","2026-06-11 04:11:48","CREATED_QUERY"]