# When to Use Multiple BrowserWindow Instances in Electron: 8 Proven Patterns

> Create multiple BrowserWindow instances in Electron for distinct OS windows. Learn 8 proven patterns for independent processes, security contexts, and native behaviors. Optimize your app now.

- Repository: [Electron/electron](https://github.com/electron/electron)
- Tags: best-practices
- Published: 2026-02-25

---

**You should create multiple `BrowserWindow` instances in Electron whenever your application needs distinct OS-level windows with independent renderer processes, isolated security contexts, or native platform behaviors like modals and tabbed interfaces.**

Each `BrowserWindow` in the **electron/electron** repository represents a native operating system window that owns a separate `WebContents` process. Because every window runs its own renderer, architecting your application with multiple `BrowserWindow` instances provides the primary mechanism for separating UI concerns, isolating crashes, and implementing platform-native window management. The idiomatic approach follows the core Electron architecture where the main process coordinates independent renderer windows via IPC channels.

## Why Multiple BrowserWindows Are Essential

According to the Electron source code in [`lib/browser/api/browser-window.ts`](https://github.com/electron/electron/blob/main/lib/browser/api/browser-window.ts), the `BrowserWindow` class creates native OS window handles and instantiates separate `WebContents` objects for each instance. This separation is fundamental: each window operates in its own renderer process (or sandboxed thread), meaning JavaScript crashes, memory leaks, or infinite loops in one window cannot destabilize others.

The main process serves as the hub for all window communication, managing lifecycles through `ipcMain` and coordinating state via `BrowserWindow.getAllWindows()`. This multi-process architecture makes multiple windows the correct pattern for any application requiring true OS-level window semantics rather than merely visual separation.

## When to Create Separate BrowserWindow Instances

### Distinct UI Sections and Tool Windows

Create separate windows when you need floating toolboxes, inspectors, or companion panels that users can position independently from the main application window. Each `BrowserWindow` accepts distinct constructor options for size, position, chrome, and layering.

In [`docs/api/browser-window.md`](https://github.com/electron/electron/blob/main/docs/api/browser-window.md), the API documentation specifies that child windows can maintain a parent relationship while retaining independent renderer processes. This allows a main editor window and a floating toolbox to coexist with different `alwaysOnTop`, `frame`, and `transparent` settings.

```javascript
const { BrowserWindow } = require('electron')

const mainWindow = new BrowserWindow({ width: 1200, height: 800 })
mainWindow.loadFile('editor.html')

const toolbox = new BrowserWindow({
  width: 300,
  height: 600,
  parent: mainWindow,
  alwaysOnTop: true,
  frame: false,
  transparent: true
})
toolbox.loadFile('toolbox.html')

```

### Modal Dialogs and Parent-Child Relationships

Use the `parent` and `modal: true` options when implementing native dialog patterns that block interaction with parent windows. According to the *Modal windows* section in [`docs/api/browser-window.md`](https://github.com/electron/electron/blob/main/docs/api/browser-window.md), modal windows preserve renderer isolation while enforcing OS-native window blocking semantics.

```javascript
function showSaveDialog(parentWindow) {
  const modal = new BrowserWindow({
    parent: parentWindow,
    modal: true,
    show: false,
    width: 400,
    height: 200
  })
  modal.loadFile('save-dialog.html')
  modal.once('ready-to-show', () => modal.show())
}

```

### Isolating Independent Tasks and Crash Resilience

For applications like chat clients or email managers that open separate windows per conversation, multiple `BrowserWindow` instances prevent a single renderer crash from terminating the entire application. As implemented in the window management internals under `src/browser/window-manager`, each window's `webContents` runs independently, ensuring that heavy JavaScript execution in one conversation window does not freeze the main interface.

### Enforcing Different Security Contexts

Configure separate `webPreferences` for windows requiring different security postures. The [`docs/api/structures/browser-window-options.md`](https://github.com/electron/electron/blob/main/docs/api/structures/browser-window-options.md) specifies that each window can have distinct `contextIsolation`, `sandbox`, `nodeIntegration`, and `session` objects.

```javascript
// Privileged admin interface with Node access
const adminWindow = new BrowserWindow({
  webPreferences: { 
    nodeIntegration: true, 
    contextIsolation: false 
  }
})
adminWindow.loadFile('admin.html')

// Sandboxed guest content for untrusted URLs
const guestWindow = new BrowserWindow({
  webPreferences: { sandbox: true }
})
guestWindow.loadURL('https://untrusted-source.com')

```

### Platform-Native Window Types

Implement macOS sheets, Windows dialog boxes, or Linux-specific window types by creating specialized `BrowserWindow` instances with platform-specific options like `type: 'toolbar'` or `titleBarStyle: 'hiddenInset'`. These native experiences require separate OS window handles that only distinct `BrowserWindow` objects can provide.

### Performance Isolation for Heavy Content

Dedicate separate GPU processes to windows running WebGL, video playback, or canvas animations. Because each `BrowserWindow` maintains its own renderer process, heavy graphics work in one window cannot cause frame drops in lightweight UI windows, leveraging the multi-process architecture described in [`lib/browser/api/browser-window.ts`](https://github.com/electron/electron/blob/main/lib/browser/api/browser-window.ts).

### Native Tabbed Windows on macOS

Implement macOS-native tabbed interfaces using the `tabbingIdentifier` option. Windows sharing the same identifier automatically group as tabs in the OS tab bar, yet each tab remains a distinct `BrowserWindow` instance with independent `webContents`. This feature is documented in the *Parent and child windows* section of the official API documentation.

## When to Avoid Extra BrowserWindows

If your application only requires visual separation without OS-level window semantics, avoid creating additional `BrowserWindow` instances. Each extra window consumes native OS handles and GPU contexts, increasing resource overhead.

For in-application navigation, single-page routing, or embedded content panels, use `BrowserView` instead. A `BrowserView` attaches to an existing window's `webContents` without creating a separate native window, making it ideal for split-pane layouts or in-window tabs where you do not need the user to move components independently at the OS level.

## Implementation Examples

### Creating Tool Windows and Main Windows

The standard pattern from [`spec/api-browser-window-spec.ts`](https://github.com/electron/electron/blob/main/spec/api-browser-window-spec.ts) demonstrates instantiating multiple windows with different parent relationships:

```javascript
const { app, BrowserWindow } = require('electron')

app.whenReady().then(() => {
  const main = new BrowserWindow({ width: 800, height: 600 })
  main.loadFile('index.html')
  
  const floating = new BrowserWindow({
    width: 300,
    height: 400,
    parent: main,
    alwaysOnTop: true
  })
  floating.loadFile('panel.html')
})

```

### Managing All Windows Programmatically

The static `BrowserWindow.getAllWindows()` method, defined in the API documentation, returns an array of all instantiated windows for bulk operations:

```javascript
const { BrowserWindow, app } = require('electron')

app.on('before-quit', () => {
  const allWindows = BrowserWindow.getAllWindows()
  allWindows.forEach(win => {
    const bounds = win.getBounds()
    // Persist bounds to configuration store
    config.set(`window-state-${win.id}`, bounds)
  })
})

```

### Configuring Different Security Policies

As specified in [`docs/api/structures/browser-window-options.md`](https://github.com/electron/electron/blob/main/docs/api/structures/browser-window-options.md), each window's `webPreferences` object operates independently:

```javascript
// Secure window for internal tools
const secureWin = new BrowserWindow({
  webPreferences: {
    contextIsolation: true,
    preload: path.join(__dirname, 'preload-safe.js')
  }
})

// Restricted window for external content
const restrictedWin = new BrowserWindow({
  webPreferences: {
    sandbox: true,
    contextIsolation: true,
    allowRunningInsecureContent: false
  }
})

```

## Summary

- **Multiple `BrowserWindow` instances** provide separate renderer processes that isolate crashes and performance issues.
- **Parent-child relationships** with `modal: true` create native OS dialog behaviors while maintaining process separation.
- **Independent `webPreferences`** allow mixing privileged Node.js access with sandboxed, untrusted content in the same application.
- **`tabbingIdentifier`** enables macOS-native tabbed windows without sacrificing renderer isolation.
- **`BrowserWindow.getAllWindows()`** provides the main process with centralized lifecycle management for all windows.
- **Avoid extra windows** when `BrowserView` or in-application routing can provide sufficient visual separation without OS window overhead.

## Frequently Asked Questions

### How many BrowserWindow instances can an Electron app create?

There is no enforced limit within Electron itself, but you are constrained by operating system resources and GPU memory. As noted in the window management implementation, each instance creates native OS handles and renderer processes. Practical limits vary by platform—macOS and Windows typically handle dozens of windows well, but mobile-style applications should minimize window count to prevent resource exhaustion.

### Does creating multiple BrowserWindow instances affect application performance?

Each `BrowserWindow` spawns a separate renderer process (or thread), which increases memory footprint proportionally. However, this separation prevents performance degradation in individual windows from affecting the entire application. According to the architecture in [`lib/browser/api/browser-window.ts`](https://github.com/electron/electron/blob/main/lib/browser/api/browser-window.ts), GPU-intensive work in one window cannot block the main thread or other renderers, making multiple windows the correct pattern for performance isolation.

### Can BrowserWindows share data without using IPC?

No. Because each `BrowserWindow` owns a distinct `WebContents` process, they run in isolated JavaScript contexts by design. The Electron architecture requires `ipcMain` and `ipcRenderer` for all cross-window communication. Shared state must flow through the main process or a dedicated state management layer that coordinates via IPC channels, as the renderer processes have no direct memory access to each other.

### What is the difference between a modal BrowserWindow and a dialog?

A modal `BrowserWindow` is a full renderer process with HTML/CSS content that blocks parent window interaction via `modal: true`, while system dialogs (`dialog.showOpenDialog`, etc.) are native OS implementations. Modal windows offer complete UI customization but consume more resources. Use modal `BrowserWindow` instances for complex custom interfaces; use native dialogs for standard file pickers and message boxes to ensure platform-consistent behavior and lower overhead.