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

react-native-webview-stream-chunks

v0.4.0

Published

Reusable preload script and event types for streaming large HTML/chunks into WebView

Readme

react-native-webview-stream-chunks

Stream large payloads into a React Native WebView by chunking, inject them as <script> tags, and optionally re-execute scripts — through a high-level sender API.

Features

  • High-level sender (WebViewStreamSender) instead of manual low-level events.
  • Per-injection script options on finalizePayload(options).
  • Supports injecting multiple different script tags in one session.
  • Optional script re-execution (all via default selector, or specific selector).

Install

npm install react-native-webview-stream-chunks
# or
pnpm add react-native-webview-stream-chunks

Quick Start

1) Generate the preload script (receiver side)

import { createWebViewStreamChunksPreloadScript } from 'react-native-webview-stream-chunks';

const preloadScript = createWebViewStreamChunksPreloadScript({
  receiverReadyCallbackPath: 'window.onReady', // Optional
});

Inject preloadScript into your WebView (for example with injectedJavaScript).

2) Send data from React Native (sender side)

import { WebViewStreamSender } from 'react-native-webview-stream-chunks';

const sender = new WebViewStreamSender((type, data) => {
  const message = JSON.stringify({ type, data });
  webViewRef.current?.injectJavaScript(`window.onStreamChunksToWebView(${message});`);
});

sender.checkReceiverReady();
sender.setContent(skeletonHtml);

for (const chunk of chunks) {
  sender.appendChunk(chunk);
}

sender.finalizePayload({
  scriptType: 'application/json',
  scriptClassName: 'my-payload-store',
  scriptTagName: 'main-store',
  anchorSelector: '#styleArea',
});

sender.reexecuteScripts();
// sender.reexecuteScripts('script[data-boot]');

3) Inject multiple script tags

// First payload
for (const chunk of firstChunks) sender.appendChunk(chunk);
sender.finalizePayload({
  scriptType: 'application/json',
  scriptClassName: 'store-a',
  scriptTagName: 'users',
  anchorSelector: '#styleArea',
});

// Second payload
for (const chunk of secondChunks) sender.appendChunk(chunk);
sender.finalizePayload({
  scriptType: 'text/javascript',
  scriptClassName: 'boot-script',
  scriptTagName: 'runtime',
  anchorSelector: '#styleArea',
});

API

WebViewStreamSender

| Method | Description | | ----------------------------- | ----------------------------------------------------------------------- | | checkReceiverReady() | Ping receiver and trigger its configured ready callback path. | | setContent(html) | Replace document.body.innerHTML and reset buffered chunks. | | appendChunk(chunk) | Append one payload chunk to the receiver buffer. | | finalizePayload(options?) | Join buffered chunks and inject one <script> with per-call options. | | reexecuteScripts(selector?) | Re-execute matching script tags by clone-replace. Defaults to script. |

finalizePayload(options)

| Option | Default | Description | | ----------------- | ------------------------ | ------------------------------------------------------------------------------- | | scriptType | application/json | type attribute of injected <script>. | | scriptClassName | webview-stream-payload | Class used for this payload script (also used to exclude it from re-execution). | | scriptTagName | default-payload | Extra class/name tag for easier identification. | | anchorSelector | #styleArea | Inject payload script after this element. |

Preload options

| Option | Default | Description | | --------------------------- | ------- | ------------------------------------------------------------------ | | receiverReadyCallbackPath | '' | (Optional) Dot-path on window invoked by checkReceiverReady(). |