{"id":20499,"library":"react-native-fetch-api","title":"React Native Fetch API","description":"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.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/react-native-community/fetch","tags":["javascript","react-native","fetch","stream"],"install":[{"cmd":"npm install react-native-fetch-api","lang":"bash","label":"npm"},{"cmd":"yarn add react-native-fetch-api","lang":"bash","label":"yarn"},{"cmd":"pnpm add react-native-fetch-api","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package exports a default fetch function. Named import is incorrect.","wrong":"import { fetch } from 'react-native-fetch-api'","symbol":"fetch","correct":"import fetch from 'react-native-fetch-api'"},{"note":"Headers is a named export, not a default export. Both fetch and Headers are available.","wrong":"import Headers from 'react-native-fetch-api'","symbol":"Headers","correct":"import { Headers } from 'react-native-fetch-api'"},{"note":"Request is a named export. Use the same pattern for Response and AbortController if needed.","wrong":"import Request from 'react-native-fetch-api'","symbol":"Request","correct":"import { Request } from 'react-native-fetch-api'"}],"quickstart":{"code":"import fetch, { Headers, Request, Response } from 'react-native-fetch-api';\n\nasync function streamText() {\n  const response = await fetch('https://example.com/data', {\n    method: 'GET',\n    headers: new Headers({ 'Accept': 'text/plain' })\n  });\n  const reader = response.body.getReader();\n  const decoder = new TextDecoder();\n  let result = '';\n  while (true) {\n    const { done, value } = await reader.read();\n    if (done) break;\n    result += decoder.decode(value, { stream: true });\n  }\n  console.log(result);\n}\nstreamText().catch(console.error);","lang":"typescript","description":"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."},"warnings":[{"fix":"Remove any await on Response construction: const response = new Response(body, init); (not await new Response(...))","message":"Response NOW returns the instance directly instead of a Promise","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Install and import 'abort-controller' polyfill (e.g., from npm) and use AbortController from there.","message":"AbortController is NOT included in this package; must use a polyfill","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use responseType: 'text' (default) for streaming. For binary, use blob or base64 – note that streaming is not supported.","message":"Streaming only works for text response types; binary data is collected as a single chunk","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use new Response(body, { status, statusText, headers }) instead of new Response(body, status, statusText, headers)","message":"The 'text' parameter in Response constructor is deprecated; use init object instead","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Use a different method for non-HTTP URLs (e.g., react-native-fs for local files)","message":"fetch() does not support custom protocols (e.g., file://) – only http/https","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install abort-controller: npm install abort-controller, then import AbortController from 'abort-controller'.","cause":"react-native-fetch-api does not ship its own AbortController; you need a polyfill.","error":"AbortController is not defined"},{"fix":"Use import { Response } from 'react-native-fetch-api' instead of import Response from ...","cause":"Importing Response as default instead of named export.","error":"Response is not a constructor"},{"fix":"Construct Response with an init object: new Response(body, { status: 200 })","cause":"Using deprecated positional arguments instead of init object in v2+.","error":"TypeError: Failed to construct 'Response': The provided value is not of type '(ResponseInit or...)'"},{"fix":"Ensure URLs start with http:// or https://. For Android, check AndroidManifest.xml for INTERNET permission.","cause":"Possibly using a non-http/https URL or missing permissions in iOS/Android.","error":"Network request failed (or similar native error)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}