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
Section titled “Supported Platforms”This plugin requires a Rust version of at least 1.77.2
| Platform | Level | Notes |
|---|---|---|
| windows | ||
| linux | ||
| macos | ||
| android | ||
| ios |
Install the store plugin to get started.
Use your project’s package manager to add the dependency:
npm run tauri add storeyarn run tauri add storepnpm tauri add storedeno task tauri add storebun tauri add storecargo tauri add storeRun the following command in the
src-taurifolder to add the plugin to the project’s dependencies inCargo.toml:cargo add tauri-plugin-store@2src-tauri/Cargo.toml tauri-plugin-opener = "2"serde = { version = "1", features = ["derive"] }serde_json = "1"tauri-plugin-store = "2"# Read the optimization guideline for more details: https://tauri.app/concept/size/#cargo-configurationModify
lib.rsto initialize the plugin. The example app keeps its builder chain in aconfigurefunction thatruncalls, so the plugin registers there. If yourrunholds the chain, add the same line there:src-tauri/src/lib.rs pub fn configure<R: tauri::Runtime>(builder: tauri::Builder<R>) -> tauri::Builder<R> {builder.plugin(tauri_plugin_opener::init()).plugin(tauri_plugin_store::Builder::default().build()).invoke_handler(tauri::generate_handler![greet])}Install the JavaScript Guest bindings using your preferred JavaScript package manager:
npm install @tauri-apps/plugin-storeyarn add @tauri-apps/plugin-storepnpm add @tauri-apps/plugin-storedeno add npm:@tauri-apps/plugin-storebun add @tauri-apps/plugin-store
Load a store, set and read a value back, then save it. When using
"withGlobalTauri": true, you may use const {load} = window.__TAURI__.store; instead of the import; setting autoSave to a number
(or leaving the options empty) saves changes to disk after a debounce delay,
100ms by default:
import { invoke } from "@tauri-apps/api/core";import { load } from "@tauri-apps/plugin-store";
let greetInputEl: HTMLInputElement | null;let greetMsgEl: HTMLElement | null; }}
window.addEventListener("DOMContentLoaded", () => {window.addEventListener("DOMContentLoaded", async () => { greetInputEl = document.querySelector("#greet-input"); greetMsgEl = document.querySelector("#greet-msg"); document.querySelector("#greet-form")?.addEventListener("submit", (e) => { e.preventDefault(); greet(); });
// Create a new store or load the existing one; the options are ignored if // a `Store` with that path has already been created const store = await load("store.json", { autoSave: false });
// Set a value. await store.set("some-key", { value: 5 });
// Get a value. const val = await store.get<{ value: number }>("some-key"); console.log(val); // { value: 5 }
// You can manually save the store after making changes; // otherwise it saves upon graceful exit. await store.save();});The same store is available on the Rust side through the StoreExt trait —
here in the app’s setup hook:
use serde_json::json;use tauri_plugin_store::StoreExt;
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/#[tauri::command]fn greet(name: &str) -> String { .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_store::Builder::default().build()) .invoke_handler(tauri::generate_handler![greet]) .setup(|app| { // Create a new store or load the existing one; this also puts the // store in the app's resource table so later `store` calls (from // both Rust and JS) reuse the same store. let store = app.store("store.json")?;
// Note that values must be serde_json::Value instances, otherwise // they are not compatible with the JavaScript bindings. store.set("some-key", json!({ "value": 5 }));
// Get a value from the store. let value = store.get("some-key").expect("Failed to get value from store"); println!("{}", value); // {"value":5}
// Flush the pending auto-save before releasing the store: dropping a // store with one still pending deadlocks in tauri-plugin-store 2.4.4. store.save()?;
// Remove the store from the resource table. store.close_resource();
Ok(()) })}
#[cfg_attr(mobile, tauri::mobile_entry_point)]LazyStore
Section titled “LazyStore”There’s also a high level JavaScript API LazyStore which only loads the store on first access
import { LazyStore } from '@tauri-apps/plugin-store';
const store = new LazyStore('settings.json');Migrating from v1 and v2 beta/rc
Section titled “Migrating from v1 and v2 beta/rc”import { Store } from '@tauri-apps/plugin-store';import { LazyStore } from '@tauri-apps/plugin-store';with_store(app.handle().clone(), stores, path, |store| { store.insert("some-key".to_string(), json!({ "value": 5 }))?; Ok(())});let store = app.store(path)?;store.set("some-key".to_string(), json!({ "value": 5 }));Permissions
Section titled “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.
Until the capability grants the store permissions, loading a store from the
webview is denied by the ACL; with store:default granted it succeeds:
"windows": ["main"], "permissions": [ "core:default", "opener:default" "opener:default", "store:default" ]}Default Permission
This permission set configures what kind of operations are available from the store plugin.
Granted Permissions
All operations are enabled by default.
This default permission set includes the following:
allow-loadallow-get-storeallow-setallow-getallow-hasallow-deleteallow-clearallow-resetallow-keysallow-valuesallow-entriesallow-lengthallow-reloadallow-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. |
© 2026 Tauri Contributors. CC-BY / MIT