Skip to content

Global Properties

Electrobun injects these values before application scripts run. They do not require an Electroview instance.

window.__electrobunWebviewId

The numeric native ID of the current BrowserView.

import "electrobun/view";
console.log("Current webview", window.__electrobunWebviewId);

window.__electrobunWindowId

The numeric native ID of the containing window.

import "electrobun/view";
console.log("Containing window", window.__electrobunWindowId);

window.__electrobunPlatform

The native platform name: "macos", "windows", or "linux".

import "electrobun/view";
if (window.__electrobunPlatform === "macos") {
document.documentElement.dataset.platform = "macos";
}

window.__electrobunSendToHost()

Emits the value as a host-message event on the containing BrowserView or <electrobun-webview> element. The event-only bridge remains available in a sandboxed embedded webview.

import "electrobun/view";
window.__electrobunSendToHost({
type: "ready",
title: document.title,
});

Other __electrobun* globals are transport implementation details. Do not use them as application APIs; their names and shapes may change independently of the public SDK.