Documentation Index
Fetch the complete documentation index at: https://mintlify.com/l-xiaoshen/handstage/llms.txt
Use this file to discover all available pages before exploring further.
V3Context is the object that wires CDP target events into Page instances and exposes context-level APIs for cookies, init scripts, and extra HTTP headers. You receive a V3Context from browser.context (the default context) or from browser.create() / context.createBrowserContext() (an isolated context).
Every V3Context has a browserContextId that scopes all storage and network operations. Default contexts and dedicated (incognito-style) contexts behave identically from the API surface.
Page management
context.newPage
Open a new browser tab. The method creates a CDP target, waits for it to attach, and returns the resulting Page once ready.
URL to navigate to after the tab opens. Navigation is fire-and-forget after attach, so the page may still be loading when the method returns.
Promise<Page>
context.pages
Return all top-level pages (tabs) in this context, ordered from oldest to newest. Out-of-process iframes are not included.
Page[]
context.activePage
Return the most recently activated page, or undefined if no pages exist.
Page | undefined
context.setActivePage
Mark a specific page as the active one and bring it to the foreground in headed Chrome.
A
Page instance that belongs to this context.void
context.awaitActivePage
Like activePage(), but waits briefly if a popup or new tab was just opened. Useful when clicking a link that opens a new window.
Maximum time to wait for a new page to appear, in milliseconds.
Promise<Page>
Throws PageNotFoundError if no page is available within the timeout.
Cookie management
context.cookies
Return all cookies in this browser context. When one or more URLs are supplied, only cookies whose domain, path, and secure attributes match are returned.
Optional URL or list of URLs to filter by.
Promise<Cookie[]>
Cookie type
Cookie name.
Cookie value.
Cookie domain (e.g.,
".example.com").Cookie path.
Unix timestamp in seconds.
-1 means session cookie.Whether the cookie is HTTP-only.
Whether the cookie is secure.
SameSite attribute value.
context.addCookies
Set one or more cookies in this browser context. Each cookie must specify either a url (from which domain, path, and secure are derived) or an explicit domain + path pair.
Array of cookie descriptors to set.
Promise<void>
Throws CookieSetError if the browser rejects the batch.
CookieParam type
Cookie name.
Cookie value.
Convenience field: derive
domain, path, and secure from this URL. Provide url or domain+path, not both.Cookie domain.
Cookie path.
Unix timestamp in seconds. Omit or pass
-1 for a session cookie.HTTP-only flag.
Secure flag.
SameSite attribute.
context.clearCookies
Clear cookies from this browser context. Called with no arguments, all cookies are removed atomically. Called with filter options, matching cookies are removed while non-matching ones are preserved.
Optional filter. Cookies matching all provided criteria are removed.
Promise<void>
ClearCookieOptions type
Match cookies by exact name or regular expression.
Match cookies by exact domain or regular expression.
Match cookies by exact path or regular expression.
Scripts and headers
context.addInitScript
Register a script to run at document start on every page in this context, including pages that open in the future. Scripts are not inherited by child contexts created via createBrowserContext.
A JavaScript expression string or a serializable function. Functions are stringified and invoked with the optional
arg.JSON-serializable argument passed to the script function.
Promise<void>
context.setExtraHTTPHeaders
Attach additional HTTP headers to every request made by any page in this context. Headers set here apply to all sessions, including those of out-of-process iframes.
Key–value pairs of header names and values.
Promise<void>
Throws HandstagesSetExtraHTTPHeadersError if one or more CDP sessions fail to apply the headers.
Context lifecycle
context.createBrowserContext
Create a new isolated browser context that shares the underlying CDP connection but has its own cookies, storage, and pages. The returned context is tracked weakly so the parent can close it during cleanup if needed.
Options for the new context.
Promise<V3Context>
CreateContextOptions type
When
true, Chrome automatically disposes the context if the CDP connection drops unexpectedly.Proxy server URL to use for requests from this context (e.g.,
"http://proxy.example.com:8080").Comma-separated list of hosts that bypass the proxy.
Origins granted unrestricted network access regardless of CORS or mixed-content policies.
context.close
Tear down this context. Closes all child contexts, removes all event listeners, closes every page, and disposes the browser context on the CDP side. For the default context, the underlying CDP connection is also closed.
Promise<void>
Calling close() more than once is safe — subsequent calls are no-ops.