API Reference
June 6, 2026 ยท View on GitHub
fetch(input, init)
- Drop-in replacement for the global
fetch. - Accepts
Headers, array pairs, or plain object forinit.headers. - Body supports:
string,URLSearchParams,FormData, andBlob. - Returns a spec-compliant
Responsewithtext(),json(),arrayBuffer(),blob(),bytes(),clone(), abodystream, andheaders.
Example
import { fetch } from 'react-native-nitro-fetch';
const res = await fetch('https://jsonplaceholder.typicode.com/todos/1');
const data = await res.json();
nitroFetchOnWorklet(input, init, mapWorklet, options?)
- Runs the network request and then invokes
mapWorkleton a worklet runtime, falling back to the JS thread whenreact-native-workletsisn't installed. mapWorklet(payload)receives{ url, status, statusText, ok, redirected, headers, bodyBytes?, bodyString? }.options.preferBytes(defaultfalse) controls whetherbodyBytesorbodyStringis sent to the mapper.
Example
import { nitroFetchOnWorklet } from 'react-native-nitro-fetch';
const map = (payload: { bodyString?: string }) => {
'worklet';
return JSON.parse(payload.bodyString ?? '{}');
};
const data = await nitroFetchOnWorklet('https://httpbin.org/get', undefined, map, { preferBytes: false });
prefetch(input, init)
- Starts a background request in native when possible. Requires a
prefetchKeyprovided either viaheaders: { prefetchKey }orinit.prefetchKey. - Later, call
fetch(url, { headers: { prefetchKey } })to consume a fresh or pending prefetched result. - On success, response will include header
nitroPrefetched: true.
prefetchOnAppStart(input, { prefetchKey })
- Enqueues a request to be prefetched at the next app start by writing into native storage under
nitrofetch_autoprefetch_queue. Replayed on the next cold start on both Android and iOS.
removeFromAutoPrefetch(prefetchKey) / removeAllFromAutoprefetch()
- Utilities to manage the auto-prefetch queue.
Types
NitroRequest:{ url, method?, headers?: { key, value }[], bodyString?, bodyBytes?, timeoutMs?, followRedirects? }.NitroResponse:{ url, status, statusText, ok, redirected, headers, bodyString?, bodyBytes? }.