Registry / messaging / fetch-native-bridge

fetch-native-bridge

JSON →
library0.1.3jsnpmunverified

A fetch wrapper that bridges HTTP requests from a React Native WebView to the native app, enabling file downloads and other network operations that cannot be handled inside a WebView. Current stable version is 0.1.3, released as a new package with no prior major versions. Key differentiators: provides a drop-in `fetchBridge()` replacement that works identically to `fetch` in browsers, uses a message-passing pattern via `postMessage`/`onMessage`, and offers a `setupFetchHandler()` hook on the native side with optional `onFetch` callback for custom response handling (e.g., saving files to disk). Ships TypeScript types and requires `react-native >=0.70.0` and `react-native-webview >=11.0.0` as peer dependencies. The library does not transfer credentials (cookies, tokens) from the WebView; authentication must be handled natively.

messaging
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ESM-only; the package ships TypeScript types so named import is always used.

import { fetchBridge } from 'fetch-native-bridge'

This is a named export, not default.

import { isReactNativeWebView } from 'fetch-native-bridge'

Must import from the /native subpath; it's not exported from the main entry.

import { setupFetchHandler } from 'fetch-native-bridge/native'

Replaces fetch() with fetchBridge() in a React Native WebView; includes timeout and bearer token.

import { fetchBridge } from 'fetch-native-bridge'; const response = await fetchBridge('https://api.example.com/file.pdf', { method: 'GET', headers: { Authorization: `Bearer ${process.env.TOKEN ?? ''}` }, timeout: 60000, }); const blob = await response.blob();
Debug
Known footguns
gotchaCredentials (cookies, tokens) are not transferred from the WebView; authentication must be provided natively.
gotchafetchBridge only works inside a React Native WebView; in a normal browser it behaves like fetch but will not bridge to native.
gotchasetupFetchHandler must be imported from 'fetch-native-bridge/native', not from the main entry point.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
14 hits · last 30 days
gptbot
3
ahrefsbot
1
bytedance
1
Resources