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 withapp.createBrowserWindow() and attach a webview. All windows start together when the shared event loop runs.
Tracking windows
Child (popup) windows
Useapp.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.Window lifecycle events
Listen for lifecycle events on theApplication 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
Callwin.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.Related pages
- Menus — per-window and global menu bars
- IPC Messaging — communicating between windows and Node.js
- BrowserWindow API reference — full method signatures for
show,hide,setVisible,dispose, and window options