@tauri-apps/plugin-store
이 콘텐츠는 아직 번역되지 않았습니다.
Classes
Section titled “Classes”LazyStore
Section titled “LazyStore”A lazy loaded key-value store persisted by the backend layer.
Implements
Section titled “Implements”IStore
Constructors
Section titled “Constructors”new LazyStore()
Section titled “new LazyStore()”new LazyStore(path, options?): LazyStoreNote that the options are not applied if someone else already created the store
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | Path to save the store in app_data_dir |
options? | StoreOptions | Store configuration options |
Returns
Section titled “Returns”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L104
Methods
Section titled “Methods”clear()
Section titled “clear()”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.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IStore.clear
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L132
close()
Section titled “close()”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.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IStore.close
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L177
delete()
Section titled “delete()”delete(key): Promise<boolean>Removes a key-value pair from the store.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | string |
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”IStore.delete
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L128
entries()
Section titled “entries()”entries<T>(): Promise<[string, T][]>Returns a list of all entries in the store.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Returns
Section titled “Returns”Promise<[string, T][]>
Implementation of
Section titled “Implementation of”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | string |
Returns
Section titled “Returns”Promise<undefined | T>
Implementation of
Section titled “Implementation of”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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | string |
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”IStore.has
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L124
init()
Section titled “init()”init(): Promise<void>Init/load the store if it’s not loaded already
Returns
Section titled “Returns”Promise<void>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L112
keys()
Section titled “keys()”keys(): Promise<string[]>Returns a list of all keys in the store.
Returns
Section titled “Returns”Promise<string[]>
Implementation of
Section titled “Implementation of”IStore.keys
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L140
length()
Section titled “length()”length(): Promise<number>Returns the number of key-value pairs in the store.
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”IStore.length
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L152
onChange()
Section titled “onChange()”onChange<T>(cb): Promise<UnlistenFn>Listen to changes on the store.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cb | (key, value) => void |
Returns
Section titled “Returns”Promise<UnlistenFn>
A promise resolving to a function to unlisten to the event.
2.0.0
Implementation of
Section titled “Implementation of”IStore.onChange
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L171
onKeyChange()
Section titled “onKeyChange()”onKeyChange<T>(key, cb): Promise<UnlistenFn>Listen to changes on a store key.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | string | |
cb | (value) => void |
Returns
Section titled “Returns”Promise<UnlistenFn>
A promise resolving to a function to unlisten to the event.
2.0.0
Implementation of
Section titled “Implementation of”IStore.onKeyChange
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L164
reload()
Section titled “reload()”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
ignoreDefaultstotrue - This method does not emit change events.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? | ReloadOptions |
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IStore.reload
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L156
reset()
Section titled “reset()”reset(): Promise<void>Resets the store to its default value.
If no default value has been set, this method behaves identical to clear.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IStore.reset
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L136
save()
Section titled “save()”save(): Promise<void>Saves the store to disk at the store’s path.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | string | |
value | unknown |
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IStore.set
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L116
values()
Section titled “values()”values<T>(): Promise<T[]>Returns a list of all values in the store.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Returns
Section titled “Returns”Promise<T[]>
Implementation of
Section titled “Implementation of”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.
Extends
Section titled “Extends”Resource
Implements
Section titled “Implements”IStore
Accessors
Section titled “Accessors”get rid(): numberReturns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”Resource.rid
Source: undefined
Methods
Section titled “Methods”clear()
Section titled “clear()”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.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IStore.clear
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L267
close()
Section titled “close()”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.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IStore.close
Inherited from
Section titled “Inherited from”Resource.close
Source: undefined
delete()
Section titled “delete()”delete(key): Promise<boolean>Removes a key-value pair from the store.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | string |
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”IStore.delete
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L260
entries()
Section titled “entries()”entries<T>(): Promise<[string, T][]>Returns a list of all entries in the store.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Returns
Section titled “Returns”Promise<[string, T][]>
Implementation of
Section titled “Implementation of”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | string |
Returns
Section titled “Returns”Promise<undefined | T>
Implementation of
Section titled “Implementation of”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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | string |
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”IStore.has
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L253
keys()
Section titled “keys()”keys(): Promise<string[]>Returns a list of all keys in the store.
Returns
Section titled “Returns”Promise<string[]>
Implementation of
Section titled “Implementation of”IStore.keys
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L275
length()
Section titled “length()”length(): Promise<number>Returns the number of key-value pairs in the store.
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”IStore.length
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L287
onChange()
Section titled “onChange()”onChange<T>(cb): Promise<UnlistenFn>Listen to changes on the store.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cb | (key, value) => void |
Returns
Section titled “Returns”Promise<UnlistenFn>
A promise resolving to a function to unlisten to the event.
2.0.0
Implementation of
Section titled “Implementation of”IStore.onChange
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L310
onKeyChange()
Section titled “onKeyChange()”onKeyChange<T>(key, cb): Promise<UnlistenFn>Listen to changes on a store key.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | string | |
cb | (value) => void |
Returns
Section titled “Returns”Promise<UnlistenFn>
A promise resolving to a function to unlisten to the event.
2.0.0
Implementation of
Section titled “Implementation of”IStore.onKeyChange
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L299
reload()
Section titled “reload()”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
ignoreDefaultstotrue - This method does not emit change events.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? | ReloadOptions |
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IStore.reload
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L291
reset()
Section titled “reset()”reset(): Promise<void>Resets the store to its default value.
If no default value has been set, this method behaves identical to clear.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IStore.reset
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L271
save()
Section titled “save()”save(): Promise<void>Saves the store to disk at the store’s path.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | string | |
value | unknown |
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IStore.set
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L237
values()
Section titled “values()”values<T>(): Promise<T[]>Returns a list of all values in the store.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Returns
Section titled “Returns”Promise<T[]>
Implementation of
Section titled “Implementation of”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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | Path of the store. |
Returns
Section titled “Returns”Example
Section titled “Example”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
load()
Section titled “load()”static load(path, options?): Promise<Store>Create a new Store or load the existing store with the path.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | Path to save the store in app_data_dir |
options? | StoreOptions | Store configuration options |
Returns
Section titled “Returns”Example
Section titled “Example”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 Aliases
Section titled “Type Aliases”ReloadOptions
Section titled “ReloadOptions”type ReloadOptions: object;Options to IStore.reload a IStore
Type declaration
Section titled “Type declaration”| Name | Type | Description | Defined in |
|---|---|---|---|
ignoreDefaults | boolean | To fully match the store with the on-disk state, ignoring defaults | Source: 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
StoreOptions
Section titled “StoreOptions”type StoreOptions: object;Options to create a store
Type declaration
Section titled “Type declaration”| Name | Type | Description | Defined in |
|---|---|---|---|
autoSave | boolean | number | Auto save on modification with debounce duration in milliseconds, it’s 100ms by default, pass in false to disable it | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L28 |
createNew | boolean | Force 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 |
defaults | object | Default value of the store | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L24 |
deserializeFnName | string | Name of a deserialize function registered in the rust side plugin builder | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L36 |
overrideDefaults | boolean | When creating the store, override the store with the on-disk state if it exists, ignoring defaults | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/store/guest-js/index.ts#L44 |
serializeFnName | string | Name of a serialize function registered in the rust side plugin builder | Source: 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
Functions
Section titled “Functions”getStore()
Section titled “getStore()”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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | Path of the store. |
Returns
Section titled “Returns”Example
Section titled “Example”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
load()
Section titled “load()”function load(path, options?): Promise<Store>Create a new Store or load the existing store with the path.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | Path to save the store in app_data_dir |
options? | StoreOptions | Store configuration options |
Returns
Section titled “Returns”Example
Section titled “Example”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
© 2026 Tauri Contributors. CC-BY / MIT