Documentation Index
Fetch the complete documentation index at: https://mintlify.com/shadownrx/windows/llms.txt
Use this file to discover all available pages before exploring further.
useWindowManager is the most important hook in NEX OS — it exposes the complete window lifecycle API for opening, closing, minimizing, maximizing, snapping, and focusing windows. It acts as the kernel of the operating system, coordinating z-index management, virtual desktop assignments, snap layouts, and state preservation across every window instance.
Import
AppWindow Interface
Every managed window is represented as anAppWindow object in the global windows array.
Unique window identifier. Used as the primary key for all window operations — pass this to
closeWindow, focusWindow, snapWindow, and so on.Text rendered in the window’s title bar.
Icon displayed alongside the title in both the title bar and the taskbar button.
The actual application component rendered inside the window frame. Wrap heavy apps in
React.memo to prevent unnecessary re-renders when zIndex changes.The virtual desktop this window belongs to. Windows are only rendered when their
desktopId matches the currently active desktop.Whether the window is currently visible on screen. A window can exist in state but not be open (e.g., while minimized).
true when the window has been sent to the taskbar. The window’s internal React state is fully preserved — use restoreWindow to bring it back without reinitializing.true when the window occupies the full viewport. The previous size and position are saved to savedSize before maximizing.The active snap position.
'none' or undefined means the window is freely positioned.Stacking layer order. Managed automatically by
focusWindow — the focused window always receives the highest zIndex.Stores the window’s dimensions and position captured just before maximizing. Restored when the user un-maximizes, ensuring the window returns to exactly where it was.
Properties
The live array of all window instances — both open and minimized. Subscribe to this to render taskbar buttons or check for existing windows before launching a new one.
The
id of the window that currently has focus. null when no window is active (e.g., the desktop itself is focused). Used by closeFocusedWindow to implement Alt+F4.Methods
openWindow
Opens a new window, or restores and focuses the window if one with the sameid already exists in state.
Unique identifier for the window. If a window with this
id already exists, openWindow will restore it instead of creating a duplicate.Display text for the window title bar.
Icon shown in the title bar and taskbar.
The application component to render inside the window.
closeWindow
Closes the window and removes it entirely from thewindows state array.
The ID of the window to close and destroy.
minimizeWindow
Sends the window to the taskbar. The window’s internal React state is frozen in place — nothing is unmounted.The ID of the window to minimize.
minimizeAllWindows
Minimizes every open window at once. Bound to the Win+D keyboard shortcut. Equivalent to callingminimizeWindow on each entry in windows.
maximizeWindow
Toggles the maximized state of a window. When maximizing, the current dimensions and coordinates are written tosavedSize so they can be restored precisely later.
The ID of the window to maximize or un-maximize.
The window’s current size and position. Pass this so
savedSize captures the exact geometry before the window goes fullscreen.restoreWindow
Brings a minimized window back to the screen without reinitializing its content. This is the key difference fromopenWindow — the app component is not remounted, so all internal state (scroll position, text inputs, media playback) is preserved.
The ID of the minimized window to restore.
snapWindow
Docks the window to a screen region. The Window HOC applies the corresponding CSS layout (half-screen, quadrant, etc.) based on thedirection value.
The ID of the window to snap.
direction
'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'none'
required
The target snap region. Pass
'none' to release the window from a snapped position.focusWindow
Brings a window to the front by assigning it the highestzIndex value and updating focusedWindowId.
The ID of the window to bring into focus.
closeFocusedWindow
Closes whichever window is currently focused (focusedWindowId). This is the handler for the global Alt+F4 keyboard shortcut.
Usage Example
Best Practices
useWindowManager must be called inside a component that is a descendant of WindowManagerProvider. Calling it outside the provider tree throws an error.