Registry / http-networking / react-native-fetch-api

react-native-fetch-api

JSON →
library3.0.0jsnpmunverified

A fetch API polyfill for React Native built on top of the native Networking API instead of XMLHttpRequest, enabling text streaming support. Current stable version is 3.0.0 (2022-12-01). This package is maintained by the React Native community and released on an as-needed basis. Key differentiators: supports streaming text via ReadableStream (Response.body) for performance, avoids XHR overhead. Limited to text-only streaming; binary transfers do not support incremental reading. For apps requiring text streaming in React Native.

npm install react-native-fetch-api
INSTALL
IMPORT
SIG · REACT-NATIVE-FETCH
R
react-native-fetch-api
http-networkingjavascriptv3.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

fetch
import fetch from 'react-native-fetch-api'
import { fetch } from 'react-native-fetch-api'
The package exports a default fetch function. Named import is incorrect.
Headers
import { Headers } from 'react-native-fetch-api'
import Headers from 'react-native-fetch-api'
Headers is a named export, not a default export. Both fetch and Headers are available.
Request
import { Request } from 'react-native-fetch-api'
import Request from 'react-native-fetch-api'
Request is a named export. Use the same pattern for Response and AbortController if needed.

Demonstrates using the fetch API with text streaming: importing default fetch and named constructors, making a GET request, and reading the response body as a stream.

import fetch, { Headers, Request, Response } from 'react-native-fetch-api'; async function streamText() { const response = await fetch('https://example.com/data', { method: 'GET', headers: new Headers({ 'Accept': 'text/plain' }) }); const reader = response.body.getReader(); const decoder = new TextDecoder(); let result = ''; while (true) { const { done, value } = await reader.read(); if (done) break; result += decoder.decode(value, { stream: true }); } console.log(result); } streamText().catch(console.error);
Debug
Known issues
breakingResponse NOW returns the instance directly instead of a Promise
fix
Remove any await on Response construction: const response = new Response(body, init); (not await new Response(...))
affects: >=3.0.0
breakingAbortController is NOT included in this package; must use a polyfill
fix
Install and import 'abort-controller' polyfill (e.g., from npm) and use AbortController from there.
affects: >=2.0.0
gotchaStreaming only works for text response types; binary data is collected as a single chunk
fix
Use responseType: 'text' (default) for streaming. For binary, use blob or base64 – note that streaming is not supported.
affects: >=1.0.0
deprecatedThe 'text' parameter in Response constructor is deprecated; use init object instead
fix
Use new Response(body, { status, statusText, headers }) instead of new Response(body, status, statusText, headers)
affects: >=2.0.0
gotchafetch() does not support custom protocols (e.g., file://) – only http/https
fix
Use a different method for non-HTTP URLs (e.g., react-native-fs for local files)
affects: >=1.0.0
Errors
Common errors & fixes
AbortController is not defined
react-native-fetch-api does not ship its own AbortController; you need a polyfill.
fix
Install abort-controller: npm install abort-controller, then import AbortController from 'abort-controller'.
Response is not a constructor
Importing Response as default instead of named export.
fix
Use import { Response } from 'react-native-fetch-api' instead of import Response from ...
TypeError: Failed to construct 'Response': The provided value is not of type '(ResponseInit or...)'
Using deprecated positional arguments instead of init object in v2+.
fix
Construct Response with an init object: new Response(body, { status: 200 })
Network request failed (or similar native error)
Possibly using a non-http/https URL or missing permissions in iOS/Android.
fix
Ensure URLs start with http:// or https://. For Android, check AndroidManifest.xml for INTERNET permission.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
react-native-fetch-api — npm install react-native-fetch-api · libregistry