Skip to content

@tauri-apps/plugin-window-state

Save and restore window positions and sizes.

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.

import { filename } from '@tauri-apps/plugin-window-state';
const name = await filename();

Promise<string>

A promise resolving to the name of the file used to store window state.

2.0.0


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.

import { restoreState, StateFlags } from '@tauri-apps/plugin-window-state';
await restoreState('main', StateFlags.ALL);
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).

Promise<void>

2.0.0


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.

import { restoreStateCurrent, StateFlags } from '@tauri-apps/plugin-window-state';
await restoreStateCurrent(StateFlags.ALL);
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).

Promise<void>

2.0.0


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.

import { saveWindowState, StateFlags } from '@tauri-apps/plugin-window-state';
await saveWindowState(StateFlags.ALL);
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).

Promise<void>

2.0.0

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 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