Store
This plugin provides a persistent key-value store. This is one of many options to handle state in your application. See the state management overview for more information on additional options.
This store will allow you to persist state to a file which can be saved and loaded on demand including between app restarts. Note that this process is asynchronous which will require handling it within your code. It can be used both in the webview or within Rust.
Supported Platforms
This plugin requires a Rust version of at least 1.77.2
Platform | Level | Notes |
---|---|---|
windows | ||
linux | ||
macos | ||
android | ||
ios |
Setup
Install the store plugin to get started.
Use your project’s package manager to add the dependency:
-
Run the following command in the
src-tauri
folder to add the plugin to the project’s dependencies inCargo.toml
: -
Modify
lib.rs
to initialize the plugin: -
Install the JavaScript Guest bindings using your preferred JavaScript package manager:
Usage
LazyStore
There’s also a high level JavaScript API LazyStore
which only loads the store on first access
Migrating from v1 and v2 beta/rc
Permissions
By default all potentially dangerous plugin commands and scopes are blocked and cannot be accessed. You must modify the permissions in your capabilities
configuration to enable these.
See the Capabilities Overview for more information and the step by step guide to use plugin permissions.
Default Permission
This permission set configures what kind of operations are available from the store plugin.
Granted Permissions
All operations are enabled by default.
allow-load
allow-get-store
allow-set
allow-get
allow-has
allow-delete
allow-clear
allow-reset
allow-keys
allow-values
allow-entries
allow-length
allow-reload
allow-save
Permission Table
Identifier | Description |
---|---|
|
Enables the clear command without any pre-configured scope. |
|
Denies the clear command without any pre-configured scope. |
|
Enables the delete command without any pre-configured scope. |
|
Denies the delete command without any pre-configured scope. |
|
Enables the entries command without any pre-configured scope. |
|
Denies the entries command without any pre-configured scope. |
|
Enables the get command without any pre-configured scope. |
|
Denies the get command without any pre-configured scope. |
|
Enables the get_store command without any pre-configured scope. |
|
Denies the get_store command without any pre-configured scope. |
|
Enables the has command without any pre-configured scope. |
|
Denies the has command without any pre-configured scope. |
|
Enables the keys command without any pre-configured scope. |
|
Denies the keys command without any pre-configured scope. |
|
Enables the length command without any pre-configured scope. |
|
Denies the length command without any pre-configured scope. |
|
Enables the load command without any pre-configured scope. |
|
Denies the load command without any pre-configured scope. |
|
Enables the reload command without any pre-configured scope. |
|
Denies the reload command without any pre-configured scope. |
|
Enables the reset command without any pre-configured scope. |
|
Denies the reset command without any pre-configured scope. |
|
Enables the save command without any pre-configured scope. |
|
Denies the save command without any pre-configured scope. |
|
Enables the set command without any pre-configured scope. |
|
Denies the set command without any pre-configured scope. |
|
Enables the values command without any pre-configured scope. |
|
Denies the values command without any pre-configured scope. |
© 2024 Tauri Contributors. CC-BY / MIT