Skip to main content
BrowserWindow wraps a native OS window and provides full control over its appearance, behavior, and content. You create a BrowserWindow through the application factory — never via new BrowserWindow() directly — and then attach a Webview to it to display web content.

Creation Options

Pass a BrowserWindowOptions object to app.createBrowserWindow() or app.createChildBrowserWindow().

Basic

Behavior

Fullscreen

See the Menus guide for the MenuOptions shape.

Windows-specific options

macOS-specific options

iOS-specific options


Creating a Webview

Attach a browser view to the window by calling createWebview(). It returns a Webview object you use to control the content.
Hold a strong reference to the returned Webview for as long as you need it. Do not discard the wrapper into a temporary variable.
See Webview for the full WebviewOptions reference.

Window State Methods

Control visibility and window chrome at runtime:

Size and Position

All size and position methods accept an optional logical boolean. When true, values are interpreted as logical (CSS / device-independent) pixels. When false (the default), values are physical pixels.
Divide physical pixel values by win.scaleFactor() to convert them to logical pixels, which match CSS px units in the webview.

Cursor Control

CursorType values

All 35 CursorType values are available: Default · Crosshair · Hand · Arrow · Move · Text · Wait · Help · Progress · NotAllowed · ContextMenu · Cell · VerticalText · Alias · Copy · NoDrop · Grab · Grabbing · ZoomIn · ZoomOut · ResizeEast · ResizeNorth · ResizeNorthEast · ResizeNorthWest · ResizeSouth · ResizeSouthEast · ResizeSouthWest · ResizeWest · ResizeEastWest · ResizeNorthSouth · ResizeNorthEastSouthWest · ResizeNorthWestSouthEast · ResizeColumn · ResizeRow · AllScroll

Decorations and Behavior

Theme values: Theme.Light, Theme.Dark, Theme.System.

Icon and Progress Bar

Window icon

Set the window’s icon from an RGBA pixel buffer:
icon is a raw byte array of width × height × 4 bytes in RGBA order (red, green, blue, alpha, each 0–255).

Progress bar

Display a progress bar in the window’s taskbar button (Windows) or dock icon (macOS):

File Dialogs

Open a native file picker and get the selected paths. This call blocks until the user dismisses the dialog and returns the selected paths synchronously:

Monitor Info

Query information about the displays attached to the system:
Each Monitor object has:

Custom Protocols

Register a URL-scheme handler to serve your own content to the webview. You must call registerProtocol() before calling createWebview() on the same window.
The handler receives a standard Fetch API Request and should return a standard Response (compatible with Hono, itty-router, and any Fetch-API framework) or a legacy CustomProtocolResponse plain object.
See the Custom Protocols guide for a complete walkthrough.

State Properties

Read the current window state through these properties and methods:

Window Events

BrowserWindow extends Node.js EventEmitter. All positional values (x, y, width, height, deltaX, deltaY) are in physical pixels at the current DPI. Divide by win.scaleFactor() to convert to logical (CSS) pixels.

Event reference

Usage example


Identity and Native Handles

getNativeHandle() returns the platform-native handle as a bigint pointer value: Returns 0n when no supported handle is available for the current platform. Treat this as a borrowed value — do not destroy it or pass ownership to native code.

Platform-Specific Extensions

Windows

macOS

Linux (Wayland)

Android


Disposal

Call win.dispose() when you want to release a window before app.exit():
You can also use the using declaration for automatic cleanup:
Disposal is idempotent — calling it more than once is safe. Disposing a window also disposes all Webview instances attached to it. app.exit() disposes every window owned by the application.