Skip to content

Types

Bunwright exports several types for use in TypeScript projects. Import them as type-only imports:

import type {
BrowserConfig,
ContextOptions,
Selector,
LoadState,
ResolvedSelector,
} from "bunwright";
Property Type
backend? "webkit" | "chrome" | { type: "chrome"; path?: string; argv?: string[]; }
width? number
height? number
url? string
console? boolean
dataStore? "ephemeral" | string
retryTimeout? number
headless? boolean

See Configuration for usage details.

Property Type
viewport? { width: number; height: number; }
extraHeaders? Record<string, string>
cookies? Array<{ name: string; value: string; domain?: string; path?: string; }>

Used with browser.newPage() and browser.newContext():

const context = await browser.newContext({
viewport: { width: 1920, height: 1080 },
extraHeaders: { Authorization: "Bearer token" },
cookies: [{ name: "session", value: "abc", domain: "example.com" }],
});
`role:${string}` | `label:${string}` | `text:${string}` | `css:${string}` | `xpath:${string}`;

A template literal type — prefixed strings for semantic element queries. See Selectors for the full guide.

"load" | "domcontentloaded" | "networkidle";

Used with page.waitForLoadState() and page.navigate():

await page.waitForLoadState("networkidle");
await page.navigate("https://example.com", { waitForLoadState: "load" });
Property Type
css string
isCoordinate boolean
x? number
y? number

Internal type representing a resolved selector. css is the CSS path used for querySelector. isCoordinate indicates if the selector resolved to a point coordinate rather than an element.