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 aResponse object with:
status: HTTP status codestatusText: HTTP status textheaders: response headersok:trueif status is 200-299url: final URL after redirectsredirected:trueif the response is the result of a redirectbody:ReadableStream<Uint8Array>ornullbodyUsed:trueif body has been consumedcontentLength: content length from headers, ornullcookies: parsed response cookies asRecord<string, string | string[]>diagnostics: optional native diagnostics payload, ornull
Response methods
json(): parse body as JSONtext(): get body as stringarrayBuffer(): get body as ArrayBufferbytes(): get body as Uint8Arrayblob(): get body as BlobformData(): parse body as FormDataclone(): clone the response
Request lifecycle events
WhenonRequestEvent 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?)callsfetch(url, { ...init, method: "GET" }).post(url, body?, init?)callsfetch(url, { ...init, method: "POST", body }).request(options)is deprecated and kept for compatibility. Preferfetch(url, init).