Skip to main content

Navigation

See how pages expose Response objects from navigation methods

Overview

Response mirrors Playwright’s Response interface and is returned from Stagehand navigation helpers such as page.goto(), page.reload(), page.goBack(), and page.goForward(). It provides a convenient way to inspect the HTTP metadata associated with a navigation, retrieve the response body on demand, and monitor when the underlying request finishes. Stagehand automatically returns null for navigations that do not yield a network request (for example data: URLs, about:blank, or same-document history changes), matching Playwright’s behaviour.

Getting a Response

When a navigation does not produce a response object you will receive null, allowing you to branch early:

Status & Metadata

url()

Returns the final URL associated with the navigation request.

status()

Returns the HTTP status code.

statusText()

Returns the human-readable status text (for example OK).

ok()

Convenience helper that resolves to true for 2xx responses and false otherwise.

frame()

Returns the Stagehand Frame that initiated the navigation. When the frame is no longer available, null is returned.

fromServiceWorker()

Indicates whether the response was served from a Service Worker fetch handler.

securityDetails()

Resolves with TLS/security metadata when available (issuer, protocol, validity window). Returns null for insecure or non-network responses.

serverAddr()

Provides the remote IP/port reported by Chrome, when known.

Header Helpers

headers()

Returns a lowercase header map, matching Playwright’s headers() behaviour.

allHeaders()

Includes additional headers only surfaced via Chrome’s responseReceivedExtraInfo event (such as set-cookie).

headerValue()

Returns a comma-joined string of all values for the specified header. Resolves to null when the header is absent.

headerValues()

Returns an array of header values, keeping multiple entries separate.

headersArray()

Returns the header list while preserving the original casing and order reported by the browser.

Body Helpers

body()

Fetches the raw response body. The buffer is base64-decoded for you when Chrome sends it that way.

text()

Returns the response body decoded as UTF-8 text.

json()

Parses the response body as JSON. Throws if the body cannot be parsed or is not valid JSON.
All body helper calls (body(), text(), json()) only succeed once the browser reports the response body is available. Stagehand handles this timing automatically.

Completion

finished()

Resolves to null when the main navigation request completes successfully, or to an Error if Chrome reports Network.loadingFailed. This mirrors Playwright’s response.finished() contract and is especially helpful for catching late failures such as network resets or blocked responses.

Usage Patterns

Inspect status and headers

Handle non-network navigations

Await completion

Returned From

  • await page.goto(url, options?)
  • await page.reload(options?)
  • await page.goBack(options?)
  • await page.goForward(options?)
Each method resolves with Response | null depending on whether Chrome reported a document-level network response.

See Also