npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@shamilovtim/react-native-nitro-sse

v2.3.1

Published

High-performance Server-Sent Events (SSE) for React Native, powered by Nitro Modules.

Readme

react-native-nitro-sse

High-performance Server-Sent Events (SSE) client for React Native, built on top of Nitro Modules (JSI). Designed for mission-critical apps requiring high-throughput streaming, battery optimization, and extreme stability.


Why NitroSSE?

Traditional EventSource libraries run on the JS thread or use the legacy React Native Bridge. NitroSSE moves the entire control logic down to the native layer:

  • Zero-Latency JSI: Instantaneous JS-Native communication bypassing the async bridge.
  • Advanced Backpressure: Batches high-frequency events and employs tail-drop strategies to keep UI thread fluid under extreme load.
  • Intelligent Reconnect: Automatic recovery using Exponential Backoff and Jitter to prevent server stampedes.
  • Lifecycles: Auto-hibernates connections in background and resumes on foreground to preserve battery.
  • Heartbeat Watchdog: Native detection of keep-alive/ping comments to auto-reconnect dead sockets.
  • RN DevTools Integration: Plug-and-play network tracing in React Native 0.83+ DevTools (monitor streams directly).
  • Local Mocking Engine: Simulates streams, connection drops, and delays entirely in JS without backend setup.

Installation

yarn add @shamilovtim/react-native-nitro-sse react-native-nitro-modules
# or
npm install @shamilovtim/react-native-nitro-sse react-native-nitro-modules

[!NOTE]
react-native-nitro-modules is a peer dependency and must be installed in the host project.


Compatibility

| react-native-nitro-sse | react-native-nitro-modules | | :--------------------- | :------------------------- | | 2.3.1 - latest | 0.35.9 | | 2.3.0 | 0.35.6 | | 2.2.0 - 2.2.3 | 0.35.4 | | 2.0.0 - 2.1.1 | 0.35.2 | | 1.6.2 | 0.35.2 | | 1.4.0 - 1.6.1 | 0.35.0 | | 1.2.2 - 1.3.1 | 0.34.1 | | 1.2.0 - 1.2.1 | 0.34.0 | | 1.1.0 | 0.33.9 | | 1.0.0 | 0.33.8 |


Usage

import { createNitroSse } from '@shamilovtim/react-native-nitro-sse';

const sse = createNitroSse();

sse.setup({
  url: 'https://api.example.com/stream',
  headers: { 'Authorization': 'Bearer TOKEN' }
});

// Listen to events
sse.addEventListener('message', (e) => console.log('Received:', e.data));
sse.addEventListener('error', (e) => console.error('Error:', e.message));

// Start streaming
sse.start();

// Cleanup when done
// sse.stop();

Configuration Reference (SseConfig)

| Parameter | Type | Default | Description | | :--- | :--- | :--- | :--- | | url | string | — | Required. SSE endpoint target. | | method | 'get' \| 'post' | 'get' | HTTP method. | | headers | Record<string, string> | {} | Custom request headers. | | body | string | — | Payload sent during POST requests. | | backgroundExecution | boolean | false | (iOS) Keep background execution active when app is minimized. | | batchingIntervalMs | number | 0 | Batch window (ms). 0 sends events instantly. | | maxBufferSize | number | 1000 | Native memory safety threshold. | | connectionTimeoutMs| number | 15000 | Handshake connect timeout threshold. | | readTimeoutMs | number | 300000| Socket inactivity limit triggers reconnect. | | retryIntervalMs | number | 1000 | Backoff base delay (ms) for reconnect. | | maxRetryIntervalMs | number | 30000 | Cap on backoff reconnect delay (ms). | | jitterFactor | number | 0.5 | Randomization spread ratio (0.0 to 1.0). | | maxReconnectAttempts| number | -1 | Limit reconnections. -1 = infinite. 0 = disabled. | | autoParseJSON | boolean | false | Parses event data on native thread; outputs to parsedData. | | monitorNetwork | boolean | true | Pauses/resumes connection on WiFi <-> Cell or link changes. | | onBeforeRequest | () => Promise<Record<string, string>> | — | Async hook running immediately before every request. | | mock | SseMockConfig | — | Injected mock stream settings (Dev environment only). |


Mocking & Testing System (v2.3.0+)

NitroSSE includes a built-in mock streaming engine to test application responses without running live endpoints. Mocks are automatically disabled in production configurations.

Configuration (SseMockConfig)

sse.setup({
  url: 'https://api.mocked-endpoint.com/stream',
  mock: {
    mode: 'replace', // 'replace' = Pure JS local simulation; 'inject' = Server + injected events
    eventsPerSecond: 2,
    loop: true,
    errorRate: 0.1,  // 10% chance to simulate connection drops and trigger reconnects
    data: [
      { type: 'open', statusCode: 200 },
      { type: 'message', data: 'Initial greeting' },
      { event: 'user-updated', data: '{"id":123,"status":"online"}', delayMs: 1500 },
      { type: 'message', data: 'Periodic heartbeat comments' },
    ]
  }
});

Manual Injector

Inject custom testing events programmatically at runtime to mock specific app situations:

sse.injectMockEvent({
  type: 'message',
  event: 'alert',
  data: 'System maintenance warning!'
});

Advanced Operations

  • updateHeaders(headers): Change request headers (e.g., updating expired authentication tokens) without closing and opening the connection manually.
  • setLastProcessedId(id): Update the native parser's last processed event ID. Native uses this ID as the Last-Event-ID header on next reconnection.
  • restart(): Immediately tears down the current network socket and initializes fresh handshake sequence.
  • flush(): Explicitly forces dispatch of currently buffered events, ignoring batchingIntervalMs.

License

MIT


Made with create-react-native-library