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-marked windows
Useapp.createChildBrowserWindow() for windows that should be marked as child windows. The method does not accept a parent window and does not establish a native parent/owner relationship. Child windows are otherwise independent BrowserWindow instances.
child: true and provide x, y, width, and height.
Show and hide instead of destroy
When the OS delivers a close request, WebviewJS hides the native window and removes it from the application’s tracked window set. A close request for the last tracked window also shuts the application down and disposes its resources. Usewin.hide() when you want a window to remain part of the live application
and be shown again later.
Window lifecycle events
Listen for lifecycle events on theApplication instance to respond to window and application close requests.
window-close-requested fires for each OS close request. When that request
removes the last tracked window, application-close-requested fires and
shutdown follows immediately. For a tray-only workflow, hide the window rather
than allowing the last tracked window to receive an OS close request.
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 JavaScript reference to each
BrowserWindow and Webview for as long
as you need to call their methods or retain their event listeners. The
application owns the native resources; garbage-collecting a wrapper does not
itself dispose the native object.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