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

Supply width and height together, and x and y together. The native constructor reads each pair together; width without height or x without y can fail during window creation, while a lone height or y is not applied.

Behavior

Fullscreen

See the Menus guide for the MenuOptions shape.

Windows-specific options

macOS-specific options

iOS-specific options

These fields are present in the generated API for iOS builds, but the current npm package does not publish an iOS N-API binary. They are not available from a standard desktop npm installation.

Creating a Webview

Attach a browser view to the window by calling createWebview(). It returns a Webview object you use to control the content.
Keep the returned Webview wrapper available for as long as you need to call its methods or use its event listeners. The application and window retain the native resource; dropping the JavaScript wrapper does not itself dispose the native view.
See Webview for the full WebviewOptions reference.

Window State Methods

Control visibility and window chrome at runtime:
win.close() only hides the native window. An OS close-button request is a separate application event; it removes the window from the application’s tracked resources and can trigger automatic shutdown when it was the last tracked window.

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 raw RGBA pixels or encoded image bytes:
For raw RGBA pixels, provide width. With both dimensions, the byte length must be width × height × 4; with only width, it must be width × width × 4 because native treats the icon as square. If both dimensions are omitted, the bytes are decoded as an encoded image. Providing height without width is invalid.

Progress bar

Display a progress indicator in the window’s taskbar button (Windows), dock icon (macOS), or supported Linux desktop integration:

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:
On Android, openFileDialog() currently returns an empty array instead of opening a native file picker.

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

The native payload can omit x and y for mouse-enter, mouse-down, and mouse-up when no cursor position is available. Check for undefined before using those coordinates. Each file-drop and file-hover payload currently contains one path; multiple files arrive as separate native events.

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.