@tauri-apps/plugin-window-state
Save and restore window positions and sizes.
Functions
Section titled “Functions”filename()
Section titled “filename()”function filename(): Promise<string>;Defined in: plugins/window-state/guest-js/index.ts:102
Get the name of the file used to store window state.
Example
Section titled “Example”import { filename } from '@tauri-apps/plugin-window-state';
const name = await filename();Returns
Section titled “Returns”A promise resolving to the name of the file used to store window state.
2.0.0
restoreState()
Section titled “restoreState()”function restoreState(label: string, flags?: StateFlags): Promise<void>;Defined in: plugins/window-state/guest-js/index.ts:66
Restore the state for the specified window from disk.
Example
Section titled “Example”import { restoreState, StateFlags } from '@tauri-apps/plugin-window-state';
await restoreState('main', StateFlags.ALL);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
label |
string |
The label of the window to restore. |
flags? |
StateFlags |
Which parts of the state to restore. Defaults to the flags passed to the plugin Builder (all flags if none were set). |
Returns
Section titled “Returns”2.0.0
restoreStateCurrent()
Section titled “restoreStateCurrent()”function restoreStateCurrent(flags?: StateFlags): Promise<void>;Defined in: plugins/window-state/guest-js/index.ts:86
Restore the state for the current window from disk.
Example
Section titled “Example”import { restoreStateCurrent, StateFlags } from '@tauri-apps/plugin-window-state';
await restoreStateCurrent(StateFlags.ALL);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
flags? |
StateFlags |
Which parts of the state to restore. Defaults to the flags passed to the plugin Builder (all flags if none were set). |
Returns
Section titled “Returns”2.0.0
saveWindowState()
Section titled “saveWindowState()”function saveWindowState(flags?: StateFlags): Promise<void>;Defined in: plugins/window-state/guest-js/index.ts:48
Save the state of all open windows to disk.
Example
Section titled “Example”import { saveWindowState, StateFlags } from '@tauri-apps/plugin-window-state';
await saveWindowState(StateFlags.ALL);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
flags? |
StateFlags |
Which parts of the state to save. Defaults to the flags passed to the plugin Builder (all flags if none were set). |
Returns
Section titled “Returns”2.0.0
Enumerations
Section titled “Enumerations”StateFlags
Section titled “StateFlags”Defined in: plugins/window-state/guest-js/index.ts:18
Flags controlling which parts of a window’s state are saved and restored.
Combine multiple flags with the bitwise OR operator (|).
Enumeration Members
Section titled “Enumeration Members”| Enumeration Member | Value | Description | Defined in |
|---|---|---|---|
ALL |
63 |
Save and restore every flag above. | plugins/window-state/guest-js/index.ts:32 |
DECORATIONS |
16 |
Save and restore whether the window has decorations. | plugins/window-state/guest-js/index.ts:28 |
FULLSCREEN |
32 |
Save and restore whether the window is fullscreen. | plugins/window-state/guest-js/index.ts:30 |
MAXIMIZED |
4 |
Save and restore whether the window is maximized. | plugins/window-state/guest-js/index.ts:24 |
POSITION |
2 |
Save and restore the window position. | plugins/window-state/guest-js/index.ts:22 |
SIZE |
1 |
Save and restore the window size. | plugins/window-state/guest-js/index.ts:20 |
VISIBLE |
8 |
Save and restore whether the window is visible. | plugins/window-state/guest-js/index.ts:26 |
© 2026 Tauri Contributors. CC-BY / MIT