whatisgithub

What is sse-runtime?

flamefront-end/sse-runtime — explained in plain English

Analysis updated 2026-05-18

27TypeScriptAudience · developerComplexity · 3/5LicenseSetup · easy

In one sentence

sse-runtime is a fetch-based replacement for the browser's EventSource that adds auth headers, typed events, configurable reconnection, and multi-tab connection sharing.

Mindmap

mindmap
  root((sse-runtime))
    What it does
      Auth headers
      Typed events
      Configurable reconnection
      Multi-tab sharing
    Tech stack
      TypeScript core
      React package
      React Native package
    Use cases
      Protected API streaming
      Real-time apps
    Audience
      Frontend developers
      Mobile developers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Stream server updates to a protected API that requires an authorization header.

USE CASE 2

Automatically refresh an expired auth token and retry when a stream request gets a 401.

USE CASE 3

Share a single live server connection across multiple browser tabs of the same page.

USE CASE 4

Connect to a real-time event stream from a React or React Native app with automatic cleanup.

What is it built with?

TypeScriptReactReact Native

How does it compare?

flamefront-end/sse-runtime5bv57zcm44-max/noxus-ai-open-whatsappadrianhajdin/react-native-lingua
Stars272727
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasymoderatemoderate
Complexity3/54/53/5
Audiencedeveloperdevelopervibe coder

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min

Multi-tab connection sharing needs BroadcastChannel and the Web Locks API, falling back to independent connections otherwise.

MIT license: free to use, modify, and distribute, including commercially, with attribution.

So what is it?

This library fills gaps in the browser's built-in way of receiving a continuous stream of updates from a server. That built-in mechanism, called EventSource, has a well-known set of problems: it cannot send an authorization header, so it cannot be used with protected APIs that require a token. The data it delivers is untyped, meaning code that reads it has no idea what shape the data will be. Its reconnection behavior cannot be configured. And when a user opens the same page in multiple tabs, each tab opens its own separate connection to the server. sse-runtime replaces EventSource with a fetch-based implementation that addresses each of these problems. It sends custom headers including authorization tokens, and supports a hook that can refresh an expired token and retry automatically when a 401 response arrives. Event types and their data shapes are declared once, and the library enforces those types throughout so that handler code knows exactly what it is receiving. Reconnection uses a jittered delay that increases after each failure, with a configurable maximum number of retries and a way to classify specific error codes differently. For the multi-tab problem, it uses browser coordination tools to share a single real connection across all tabs showing the same page, with automatic handoff if the coordinating tab closes. The library is split into four packages. The core package has no framework dependency and can be used in any JavaScript environment. A React package wraps the core in a hook that connects when a component mounts and disconnects when it unmounts, keeping event handlers current without tearing down the connection. A React Native package provides lifecycle helpers for mobile apps. A devtools package adds a panel for inspecting live connections and event logs during development. Browser support requires fetch, ReadableStream, AbortController, and TextDecoder, which are available in all modern browsers. The multi-tab coordination feature additionally requires BroadcastChannel and the Web Locks API, and falls back to independent per-tab connections when those are not available. The project is MIT licensed.

Copy-paste prompts

Prompt 1
How do I use sse-runtime's React hook to connect to a typed event stream on mount?
Prompt 2
Set up sse-runtime with an authorization header and automatic token refresh on 401 responses.
Prompt 3
Explain how sse-runtime shares one connection across multiple browser tabs.
Prompt 4
How do I configure the reconnection retry delay and max retries in sse-runtime?

Frequently asked questions

What is sse-runtime?

sse-runtime is a fetch-based replacement for the browser's EventSource that adds auth headers, typed events, configurable reconnection, and multi-tab connection sharing.

What language is sse-runtime written in?

Mainly TypeScript. The stack also includes TypeScript, React, React Native.

What license does sse-runtime use?

MIT license: free to use, modify, and distribute, including commercially, with attribution.

How hard is sse-runtime to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is sse-runtime for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.