Skip to main content
A WebContext is a browser-data profile that controls what cookies, cache, local storage, and IndexedDB data a group of webviews can see. By passing the same context to multiple webviews you make them share a single data store — they behave like tabs in the same browser session. By giving each user or session its own context (pointing to its own directory on disk) you achieve complete isolation between them.

Creating a Context

Always create a WebContext through the application. Calling new WebContext() directly is not supported.

Creation options


Sharing Data Between Webviews

Pass the same WebContext instance to multiple createWebview() calls to give those webviews a common cookie jar, cache, and local storage.

Isolated Profiles

Create a separate context for each user or workspace to prevent any data from leaking across profiles:

In-Memory (Ephemeral) Context

Omit dataDirectory to create a context that lives only in RAM. All browser data is discarded when the context is disposed or the process exits. This is the right choice for temporary sessions, guest modes, or anything that must not leave traces on disk.

Properties and Methods

The configured persistent data directory, or null for an in-memory context.
Returns true if the given URL scheme has been registered as a custom protocol on this context’s native registry.

Enable or disable WebDriver automation support at runtime. See Automation below.

Automation

Setting allowsAutomation: true (or calling context.setAllowsAutomation(true)) enables WebDriver/CDP-based automated testing for webviews that use this context.
Automation is currently enforced only on Linux. On Linux, only one context at a time can have automation enabled. Attempting to enable it on a second context while another is already enabled will throw. Enable automation only for controlled testing environments — never in production builds.

Lifetime and Disposal

You must keep a context alive for at least as long as every webview that uses it. If you dispose a context while webviews still hold a reference to it, those webviews will encounter errors.
Disposing a WebContext while webviews are still using it leads to undefined behavior. Always dispose webviews before their context, or rely on app.exit() to clean everything up in the correct order.
app.exit() disposes all contexts created through that application automatically, in the correct order. For manual cleanup:
Disposal is idempotent — calling dispose() more than once is safe.