Skip to content
Tauri

@tauri-apps/plugin-store

A lazy loaded key-value store persisted by the backend layer.

  • IStore

new LazyStore(path, options?): LazyStore

Note that the options are not applied if someone else already created the store

ParameterTypeDescription
pathstringPath to save the store in app_data_dir
options?StoreOptionsStore configuration options

LazyStore

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L104

clear(): Promise<void>

Clears the store, removing all key-value pairs.

Note: To clear the storage and reset it to its default value, use reset instead.

Promise<void>

IStore.clear

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L132

close(): Promise<void>

Close the store and cleans up this resource from memory. You should not call any method on this object anymore and should drop any reference to it.

Promise<void>

IStore.close

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L177

delete(key): Promise<boolean>

Removes a key-value pair from the store.

ParameterTypeDescription
keystring

Promise<boolean>

IStore.delete

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L128

entries<T>(): Promise<[string, T][]>

Returns a list of all entries in the store.

Type Parameter
T

Promise<[string, T][]>

IStore.entries

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L148

get<T>(key): Promise<undefined | T>

Returns the value for the given key or undefined if the key does not exist.

Type Parameter
T
ParameterTypeDescription
keystring

Promise<undefined | T>

IStore.get

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L120

has(key): Promise<boolean>

Returns true if the given key exists in the store.

ParameterTypeDescription
keystring

Promise<boolean>

IStore.has

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L124

init(): Promise<void>

Init/load the store if it’s not loaded already

Promise<void>

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L112

keys(): Promise<string[]>

Returns a list of all keys in the store.

Promise<string[]>

IStore.keys

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L140

length(): Promise<number>

Returns the number of key-value pairs in the store.

Promise<number>

IStore.length

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L152

onChange<T>(cb): Promise<UnlistenFn>

Listen to changes on the store.

Type Parameter
T
ParameterTypeDescription
cb(key, value) => void

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event.

2.0.0

IStore.onChange

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L171

onKeyChange<T>(key, cb): Promise<UnlistenFn>

Listen to changes on a store key.

Type Parameter
T
ParameterTypeDescription
keystring
cb(value) => void

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event.

2.0.0

IStore.onKeyChange

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L164

reload(options?): Promise<void>

Attempts to load the on-disk state at the store’s path into memory.

This method is useful if the on-disk state was edited by the user and you want to synchronize the changes.

Note:

  • This method loads the data and merges it with the current store, this behavior will be changed to resetting to default first and then merging with the on-disk state in v3, to fully match the store with the on-disk state, set ignoreDefaults to true
  • This method does not emit change events.
ParameterType
options?ReloadOptions

Promise<void>

IStore.reload

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L156

reset(): Promise<void>

Resets the store to its default value.

If no default value has been set, this method behaves identical to clear.

Promise<void>

IStore.reset

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L136

save(): Promise<void>

Saves the store to disk at the store’s path.

Promise<void>

IStore.save

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L160

set(key, value): Promise<void>

Inserts a key-value pair into the store.

ParameterTypeDescription
keystring
valueunknown

Promise<void>

IStore.set

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L116

values<T>(): Promise<T[]>

Returns a list of all values in the store.

Type Parameter
T

Promise<T[]>

IStore.values

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L144


A key-value store persisted by the backend layer.

  • Resource
  • IStore

get rid(): number

number

Resource.rid

Source: undefined

clear(): Promise<void>

Clears the store, removing all key-value pairs.

Note: To clear the storage and reset it to its default value, use reset instead.

Promise<void>

IStore.clear

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L267

close(): Promise<void>

Destroys and cleans up this resource from memory. You should not call any method on this object anymore and should drop any reference to it.

Promise<void>

IStore.close

Resource.close

Source: undefined

delete(key): Promise<boolean>

Removes a key-value pair from the store.

ParameterTypeDescription
keystring

Promise<boolean>

IStore.delete

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L260

entries<T>(): Promise<[string, T][]>

Returns a list of all entries in the store.

Type Parameter
T

Promise<[string, T][]>

IStore.entries

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L283

get<T>(key): Promise<undefined | T>

Returns the value for the given key or undefined if the key does not exist.

Type Parameter
T
ParameterTypeDescription
keystring

Promise<undefined | T>

IStore.get

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L245

has(key): Promise<boolean>

Returns true if the given key exists in the store.

ParameterTypeDescription
keystring

Promise<boolean>

IStore.has

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L253

keys(): Promise<string[]>

Returns a list of all keys in the store.

Promise<string[]>

IStore.keys

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L275

length(): Promise<number>

Returns the number of key-value pairs in the store.

Promise<number>

IStore.length

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L287

onChange<T>(cb): Promise<UnlistenFn>

Listen to changes on the store.

Type Parameter
T
ParameterTypeDescription
cb(key, value) => void

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event.

2.0.0

IStore.onChange

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L310

onKeyChange<T>(key, cb): Promise<UnlistenFn>

Listen to changes on a store key.

Type Parameter
T
ParameterTypeDescription
keystring
cb(value) => void

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event.

2.0.0

IStore.onKeyChange

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L299

reload(options?): Promise<void>

Attempts to load the on-disk state at the store’s path into memory.

This method is useful if the on-disk state was edited by the user and you want to synchronize the changes.

Note:

  • This method loads the data and merges it with the current store, this behavior will be changed to resetting to default first and then merging with the on-disk state in v3, to fully match the store with the on-disk state, set ignoreDefaults to true
  • This method does not emit change events.
ParameterType
options?ReloadOptions

Promise<void>

IStore.reload

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L291

reset(): Promise<void>

Resets the store to its default value.

If no default value has been set, this method behaves identical to clear.

Promise<void>

IStore.reset

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L271

save(): Promise<void>

Saves the store to disk at the store’s path.

Promise<void>

IStore.save

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L295

set(key, value): Promise<void>

Inserts a key-value pair into the store.

ParameterTypeDescription
keystring
valueunknown

Promise<void>

IStore.set

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L237

values<T>(): Promise<T[]>

Returns a list of all values in the store.

Type Parameter
T

Promise<T[]>

IStore.values

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L279

static get(path): Promise<null | Store>

Gets an already loaded store.

If the store is not loaded, returns null. In this case you must load it.

This function is more useful when you already know the store is loaded and just need to access its instance. Prefer Store.load otherwise.

ParameterTypeDescription
pathstringPath of the store.

Promise<null | Store>

import { Store } from '@tauri-apps/api/store';
let store = await Store.get('store.json');
if (!store) {
store = await Store.load('store.json');
}

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L231

static load(path, options?): Promise<Store>

Create a new Store or load the existing store with the path.

ParameterTypeDescription
pathstringPath to save the store in app_data_dir
options?StoreOptionsStore configuration options

Promise<Store>

import { Store } from '@tauri-apps/api/store';
const store = await Store.load('store.json');

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L204

type ReloadOptions: object;

Options to IStore.reload a IStore

NameTypeDescriptionDefined in
ignoreDefaultsbooleanTo fully match the store with the on-disk state, ignoring defaultsSource: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L461

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L457


type StoreOptions: object;

Options to create a store

NameTypeDescriptionDefined in
autoSaveboolean | numberAuto save on modification with debounce duration in milliseconds, it’s 100ms by default, pass in false to disable itSource: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L28
createNewbooleanForce create a new store with default values even if it already exists.Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L40
defaultsobjectDefault value of the storeSource: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L24
deserializeFnNamestringName of a deserialize function registered in the rust side plugin builderSource: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L36
overrideDefaultsbooleanWhen creating the store, override the store with the on-disk state if it exists, ignoring defaultsSource: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L44
serializeFnNamestringName of a serialize function registered in the rust side plugin builderSource: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L32

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L20

function getStore(path): Promise<Store | null>

Gets an already loaded store.

If the store is not loaded, returns null. In this case you must load it.

This function is more useful when you already know the store is loaded and just need to access its instance. Prefer Store.load otherwise.

ParameterTypeDescription
pathstringPath of the store.

Promise<Store | null>

import { getStore } from '@tauri-apps/api/store';
const store = await getStore('store.json');

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L82


function load(path, options?): Promise<Store>

Create a new Store or load the existing store with the path.

ParameterTypeDescription
pathstringPath to save the store in app_data_dir
options?StoreOptionsStore configuration options

Promise<Store>

import { Store } from '@tauri-apps/api/store';
const store = await Store.load('store.json');

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L59


© 2025 Tauri Contributors. CC-BY / MIT