Skip to main content

Signature

Parameters

string | URL | Request
required
The resource to fetch. Can be a URL string, URL object, or a Request object.
RequestInit
Optional request configuration.

RequestInit options

string
default:"GET"
HTTP method: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS.
HeadersInit
Request headers. Can be a Headers object, plain object, or array of key-value pairs.
BodyInit | null
Request body. Supported types: string, Buffer, URLSearchParams, ArrayBuffer, ArrayBufferView (for example Uint8Array), Blob, FormData, ReadableStream<Uint8Array>, and any sync or async iterable of Uint8Array.Stream and iterable bodies are read fully into memory before the request is sent, so an unbounded stream means an unbounded allocation.
Transport
Reusable transport context for this request (proxy + emulation settings, with connection behavior handled by the native layer). When provided, you must not also set browser, os, proxy, or insecure.
BrowserProfile | BrowserAlias
default:"chrome"
Browser fingerprint profile to use (e.g., 'chrome_142', 'firefox_139'), or a family alias such as 'firefox' that resolves to the newest profile in that family. See browser profiles.
EmulationOS
Operating system to emulate: 'windows', 'macos', 'linux', 'android', 'ios'.
string
Proxy URL. Support depends on the native layer and proxy scheme.
number
default:"30000"
Request timeout in milliseconds. Set to 0 to disable the timeout.
AbortSignal
AbortSignal for cancelling the request.
'follow' | 'manual' | 'error'
default:"follow"
Redirect handling mode.
boolean
default:"false"
When true, prevents browser emulation headers from being automatically added.
boolean
default:"false"
When true, accepts invalid/self-signed certificates. Use only in development.
(event: RequestEvent) => void
Optional callback for structured request lifecycle events emitted by the native layer. Use this to observe phases such as request start, response headers, and body download progress.
boolean
default:"false"
When true, captures a final diagnostics payload on the response where supported by the native layer. This can include timing, address, and TLS peer details.

Response

Returns a Response object with:
  • status: HTTP status code
  • statusText: HTTP status text
  • headers: response headers
  • ok: true if status is 200-299
  • url: final URL after redirects
  • redirected: true if the response is the result of a redirect
  • body: ReadableStream<Uint8Array> or null
  • bodyUsed: true if body has been consumed
  • contentLength: content length from headers, or null
  • cookies: parsed response cookies as Record<string, string | string[]>
  • diagnostics: optional native diagnostics payload, or null

Response methods

  • json(): parse body as JSON
  • text(): get body as string
  • arrayBuffer(): get body as ArrayBuffer
  • bytes(): get body as Uint8Array
  • blob(): get body as Blob
  • formData(): parse body as FormData
  • clone(): clone the response
See /concepts/compatibility-matrix for detailed compatibility notes and intentional deviations.

Request lifecycle events

When onRequestEvent is provided, fetch() emits structured events from the native bridge. Each event includes a timestamp, and some events include status, url, contentLength, downloadedBytes, or message. For a full worked example, see /guides/request-events.

Convenience helpers

  • get(url, init?) calls fetch(url, { ...init, method: "GET" }).
  • post(url, body?, init?) calls fetch(url, { ...init, method: "POST", body }).
  • request(options) is deprecated and kept for compatibility. Prefer fetch(url, init).

Examples

Basic GET request

POST with JSON body

POST with form data

Observe request events and diagnostics

With timeout and abort

Reuse connections via Transport

Custom headers without defaults