Skip to main content

Webview.current

When code runs inside a WebView (e.g., in a React app loaded by CEF), Webview.current() returns a handle to that webview. Returns undefined outside a WebView context.

static current(): Webview | undefined

Returns

The current Webview instance, or undefined if not in a webview context.

Example

const webview = Webview.current();
if (webview) {
const info = await webview.info();
console.log("Viewport size:", info.viewportSize);
}

Webview.current() reads the window.WEBVIEW_ENTITY value that CEF injects into every webview context.