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-marked windows

Use app.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.
If you need a webview to occupy a specific rectangle inside its host window, create it with 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. Use win.hide() when you want a window to remain part of the live application and be shown again later.
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 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

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 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.