Skip to content

getMainWindow

Returns the app’s main window — the one the vault opened in, as opposed to any popout window.

Read from the root split, which is the one workspace container that always lives in the main window (every popout is a WorkspaceWindow under floatingSplit). Prefer this over the global window, which only happens to be the main window because plugin code runs in its context.

Import:

import { getMainWindow } from 'obsidian-dev-utils/obsidian/workspace';

Signature:

function getMainWindow(app: App): Window

Parameters:

ParameterTypeDescription
appAppThe Obsidian app.

Returns: Window — The app’s main window.


Links to this page: