@tauri-apps/plugin-store
Esta página aún no está disponible en tu idioma.
Classes
Section titled “Classes”LazyStore
Section titled “LazyStore”Source: undefined
A lazy loaded key-value store persisted by the backend layer.
Implements
Section titled “Implements”IStore
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LazyStore(path, options?): LazyStore;Source: undefined
Note 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”Methods
Section titled “Methods”clear()
Section titled “clear()”clear(): Promise<void>;Source: undefined
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.clearclose()
Section titled “close()”close(): Promise<void>;Source: undefined
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.closedelete()
Section titled “delete()”delete(key): Promise<boolean>;Source: undefined
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.deleteentries()
Section titled “entries()”entries<T>(): Promise<[string, T][]>;Source: undefined
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.entriesget<T>(key): Promise<T | undefined>;Source: undefined
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<T | undefined>
Implementation of
Section titled “Implementation of”IStore.gethas(key): Promise<boolean>;Source: undefined
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.hasinit()
Section titled “init()”init(): Promise<void>;Source: undefined
Init/load the store if it’s not loaded already
Returns
Section titled “Returns”Promise<void>
keys()
Section titled “keys()”keys(): Promise<string[]>;Source: undefined
Returns a list of all keys in the store.
Returns
Section titled “Returns”Promise<string[]>
Implementation of
Section titled “Implementation of”IStore.keyslength()
Section titled “length()”length(): Promise<number>;Source: undefined
Returns the number of key-value pairs in the store.
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”IStore.lengthonChange()
Section titled “onChange()”onChange<T>(cb): Promise<UnlistenFn>;Source: undefined
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.onChangeonKeyChange()
Section titled “onKeyChange()”onKeyChange<T>(key, cb): Promise<UnlistenFn>;Source: undefined
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.onKeyChangereload()
Section titled “reload()”reload(options?): Promise<void>;Source: undefined
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.reloadreset()
Section titled “reset()”reset(): Promise<void>;Source: undefined
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.resetsave()
Section titled “save()”save(): Promise<void>;Source: undefined
Saves the store to disk at the store’s path.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IStore.saveset(key, value): Promise<void>;Source: undefined
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.setvalues()
Section titled “values()”values<T>(): Promise<T[]>;Source: undefined
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.valuesSource: undefined
A key-value store persisted by the backend layer.
Extends
Section titled “Extends”Resource
Implements
Section titled “Implements”IStore
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get rid(): number;Source: undefined
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”Resource.ridMethods
Section titled “Methods”clear()
Section titled “clear()”clear(): Promise<void>;Source: undefined
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.clearclose()
Section titled “close()”close(): Promise<void>;Source: undefined
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.closeInherited from
Section titled “Inherited from”Resource.closedelete()
Section titled “delete()”delete(key): Promise<boolean>;Source: undefined
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.deleteentries()
Section titled “entries()”entries<T>(): Promise<[string, T][]>;Source: undefined
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.entriesget<T>(key): Promise<T | undefined>;Source: undefined
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<T | undefined>
Implementation of
Section titled “Implementation of”IStore.gethas(key): Promise<boolean>;Source: undefined
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.haskeys()
Section titled “keys()”keys(): Promise<string[]>;Source: undefined
Returns a list of all keys in the store.
Returns
Section titled “Returns”Promise<string[]>
Implementation of
Section titled “Implementation of”IStore.keyslength()
Section titled “length()”length(): Promise<number>;Source: undefined
Returns the number of key-value pairs in the store.
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”IStore.lengthonChange()
Section titled “onChange()”onChange<T>(cb): Promise<UnlistenFn>;Source: undefined
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.onChangeonKeyChange()
Section titled “onKeyChange()”onKeyChange<T>(key, cb): Promise<UnlistenFn>;Source: undefined
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.onKeyChangereload()
Section titled “reload()”reload(options?): Promise<void>;Source: undefined
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.reloadreset()
Section titled “reset()”reset(): Promise<void>;Source: undefined
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.resetsave()
Section titled “save()”save(): Promise<void>;Source: undefined
Saves the store to disk at the store’s path.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IStore.saveset(key, value): Promise<void>;Source: undefined
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.setvalues()
Section titled “values()”values<T>(): Promise<T[]>;Source: undefined
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.valuesstatic get(path): Promise<Store | null>;Source: undefined
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');}load()
Section titled “load()”static load(path, options?): Promise<Store>;Source: undefined
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');Type Aliases
Section titled “Type Aliases”ReloadOptions
Section titled “ReloadOptions”type ReloadOptions = object;Source: undefined
Options to IStore.reload a IStore
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
ignoreDefaults? |
boolean |
To fully match the store with the on-disk state, ignoring defaults | Source: undefined |
StoreOptions
Section titled “StoreOptions”type StoreOptions = object;Source: undefined
Options to create a store
Properties
Section titled “Properties”Functions
Section titled “Functions”getStore()
Section titled “getStore()”function getStore(path): Promise<Store | null>;Source: undefined
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');load()
Section titled “load()”function load(path, options?): Promise<Store>;Source: undefined
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');© 2026 Tauri Contributors. CC-BY / MIT