Skip to main content
WebviewJS drives all windows from a single event loop pump started by app.run(). Each window is an independent BrowserWindow instance with its own embedded Webview. You can create as many windows as you need before or after calling app.run(), and all of them share the same non-blocking event loop — ordinary Node timers and I/O continue running alongside native window events.

Opening multiple windows

Create each window with app.createBrowserWindow() and attach a webview. All windows start together when the shared event loop runs.
Both windows share the same event loop. There is no need to synchronise them manually.

Tracking windows

Assign a stable string or numeric ID to each window when you create it and store it in a Map. Check the Map before creating a duplicate, and call win.show() to bring an existing window to the foreground instead.

Child (popup) windows

Use app.createChildBrowserWindow() for dialogs, palettes, and tool panels that should be positioned relative to a parent window. Child windows behave like independent windows but share the parent’s native context.

Show and hide instead of destroy

When the user clicks the OS close button on a window, the WebviewJS runtime hides the window rather than destroying it. The native resources remain allocated, and you can show the window again at any time without re-creating it.
This pattern is especially useful for persistent tool windows or settings panels that users open and close frequently.

Window lifecycle events

Listen for lifecycle events on the Application instance to respond to window and application close requests.
window-close-requested fires each time a single window is hidden. application-close-requested fires once all windows are hidden. If you do not call app.exit() inside application-close-requested, the application continues running (useful for tray-only apps).

Disposal

Call win.dispose() to immediately release a window and its webview before calling app.exit(). Disposal is idempotent — calling it more than once is safe.
app.exit() disposes all root-owned windows and webviews in shutdown order. After disposal, win.isDisposed() returns true and further method calls throw a disposed error.
Keep a strong JavaScript reference to each BrowserWindow and Webview for as long as you need to call their methods or retain their event listeners. Dropping the last reference allows the garbage collector to run finalizers, which may trigger unexpected disposal.