Configuration
Every field of KmpwrightConfig and its nested types (TimeoutConfig, DebugConfig, CdpConfig, ProxyConfig, Viewport, IosSchemeInterceptionConfig) and the per-page ActionPolicy, with defaults and what each one actually changes.
KmpwrightConfig is passed once, when you create a Browser (or launchBrowser). Every page of that browser uses it.
val config = KmpwrightConfig(
timeouts = TimeoutConfig(default = 15_000, navigation = 45_000),
allowedOriginRules = setOf("https://example.com", "https://*.example.com"),
allowEval = false,
)
val browser = Browser(AndroidPlatformContext(context, webView), config)All types are immutable data classes; use copy(...) to derive variants. Source: KmpwrightConfig.kt.
KmpwrightConfig
Prop
Type
allowedOriginRules
Each rule is either an exact origin ("https://example.com", compared after normalization) or a glob matched against the origin string ("https://*.example.com"). With a non-empty set:
gototo any other origin throwsKmpwrightException: "Navigation origin is not allowed by KmpwrightConfig: url" (about:blankis always allowed),- a navigation that commits to another origin (for example after a redirect or a link click) returns or emits
ok = falsewith "Committed navigation origin is not allowed by KmpwrightConfig: url", page.read(url)andHttpReaderrefuse other origins ("HTTP read origin is not allowed"),- on Android, init scripts are registered only for these origins.
This is a configuration-time origin allowlist. For agent-browser's --allowed-domains host filter that also blocks subresources, use page.setAllowedDomains(...) (see Network).
InstallMode
| Value | Effect |
|---|---|
Automatic (default) | Installed at document start where the platform allows it, and on demand otherwise. |
Disabled | Locators, getBy*, snapshots and other APIs that need the runtime throw "Selector helpers are disabled by KmpwrightConfig.installMode". |
InputMode
| Value | Locator actions | page.touchscreen | page.mouse, page.keyboard |
|---|---|---|---|
Hybrid (default) | JVM: native CDP Input events. Android/iOS: DOM events from the page runtime. | Available | Available |
TouchOnly | JVM: clicks become CDP touch taps; other actions use DOM events. Android/iOS: DOM events. | Available | Throw KmpwrightUnsupportedException ("Native mouse requires InputMode.Hybrid" / "Native keyboard requires InputMode.Hybrid") |
JsOnly | DOM events from the page runtime on every backend. | Throws "Native touch is disabled by InputMode.JsOnly" | Throw (as above) |
TimeoutConfig
Every timeoutMs: Long? = null parameter in the API resolves against these values. A timeout that expires throws KmpwrightTimeoutException (assertions throw KmpwrightAssertionError).
Prop
Type
// Fail fast in tests, allow slow page loads.
KmpwrightConfig(timeouts = TimeoutConfig(default = 5_000, action = 5_000, waitForSelector = 5_000, navigation = 60_000))Playwright: page.setDefaultTimeout / setDefaultNavigationTimeout are per page and mutable. KMPwright sets the defaults once per Browser, has a separate bucket for assertions, and bounds dialog and route handlers (handler), which Playwright does not.
DebugConfig
Only enabled is enforced by the core (it is rejected when productionMode = true). The other flags are hints for UI integrations.
Prop
Type
CdpConfig
JVM only. See JVM for connection details.
Prop
Type
CloudProvider
| Value | Service | Required environment variable |
|---|---|---|
Browserbase | browserbase.com | BROWSERBASE_API_KEY (optional BROWSERBASE_PROJECT_ID) |
Browserless | browserless.io | BROWSERLESS_API_KEY |
BrowserUse | browser-use.com | BROWSER_USE_API_KEY |
Kernel | onkernel.com | KERNEL_API_KEY |
AutoConnect | A Chrome already running on this machine with remote debugging | none |
Every optional variable is listed on the JVM page.
ProxyConfig
An HTTP or SOCKS proxy, shaped like Playwright's proxy option. JVM only. It is used in two places:
launchBrowser(path, proxy = …)routes the launched browser's traffic (Playwright:chromium.launch({ proxy })). KMPwright passes--proxy-serverand--proxy-bypass-list.CdpConfig.connectionProxyroutes only KMPwright's WebSocket to a remote or cloud browser.
val launched = launchBrowser(
chromePath,
proxy = ProxyConfig("http://proxy.example.com:3128", bypass = listOf("localhost", "*.internal.example.com")),
)Prop
Type
Proxy authentication is not supported (Playwright's username/password), because Chromium does not accept credentials in its proxy flags. Use an unauthenticated proxy or a local forwarding proxy that adds credentials. Android WebView and WKWebView have no per-page proxy: on Android, androidx.webkit.ProxyController sets a process-wide override.
Viewport
Used by KmpwrightConfig.viewport and DeviceDescriptor.viewport (for page.emulateDevice).
Prop
Type
Presets: Viewport.DEFAULT (1280×800), Viewport.MOBILE (390×844, mobile, touch), Viewport.TABLET (768×1024, mobile, touch). Device presets live in Devices (iPhone15, iPhone15ProMax, iPhone14, iPhoneSE, iPadAir, iPadPro11, iPadPro12_9, Pixel7, Pixel7Pro, GalaxyS23, MacBook14, DesktopHD, DesktopLaptop, and Devices.all keyed by name).
IosSchemeInterceptionConfig
iOS only. See iOS network interception.
Prop
Type
ActionPolicy
Not part of KmpwrightConfig: an action policy is set per page with page.setActionPolicy(policy), like agent-browser's --action-policy. Every page action checks it first.
page.setActionPolicy(ActionPolicy(
deniedActions = setOf(ActionType.Evaluate),
confirmActions = setOf(ActionType.Navigate),
allowedDomains = setOf("example.com"),
))
page.setPolicyConfirmCallback { action, url -> askUser("Allow $action on $url?") }Prop
Type
policy.check(action, url) evaluates the rules in this order: when any domain list is set and the URL has no http(s) host, Deny; denied domains; allowed domains; denied actions; confirm actions; allowed actions; defaultAction.
ActionType values: Click, Type, Press, Navigate, Fill, Screenshot, Evaluate, Scroll, Drag, Hover, SetCookie, DeleteCookie, SetContent, AddScriptTag, AddStyleTag, Focus, Select, ReadContent (HTML, text, snapshots, cookies and storage reads), Storage (writing or clearing local/session storage), Clipboard, Network (request headers, HTTP credentials), Emulation.
Failures throw KmpwrightException: "Action denied by policy: Click", "Action Navigate requires confirmation but no confirm callback is set", or "Action denied by user confirmation: Navigate".
Related
Capabilities
How each backend reports what it supports through PageCapabilities, how to fail fast with requireCapabilities, and the full support matrix for Android WebView, iOS WKWebView and JVM Chromium.
Page
Complete reference of the Page interface and its public extension functions (selector conveniences, action-scoped waits, dialogs, tabs, agent commands), with every parameter and its default.