diff --git a/src/content/docs/plugin/store.mdx b/src/content/docs/plugin/store.mdx
index 688ffc929a..f6d9cb173e 100644
--- a/src/content/docs/plugin/store.mdx
+++ b/src/content/docs/plugin/store.mdx
@@ -76,15 +76,12 @@ Install the store plugin to get started.
```typescript
-import { createStore } from '@tauri-apps/plugin-store';
+import { load } from '@tauri-apps/plugin-store';
// when using `"withGlobalTauri": true`, you may use
-// const { createStore } = window.__TAURI__.store;
+// const { load } = window.__TAURI__.store;
// create a new store or load the existing one
-const store = await createStore('store.bin', {
- // we can save automatically after each store modification
- autoSave: true,
-});
+const store = await load('store.bin');
// Set a value.
await store.set('some-key', { value: 5 });
@@ -111,7 +108,7 @@ pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_store::Builder::default().build())
.setup(|app| {
- let store = app.handle().store_builder("store.bin").build();
+ let store = app.store("store.json")?;
// Note that values must be serde_json::Value instances,
// otherwise, they will not be compatible with the JavaScript bindings.
@@ -121,11 +118,6 @@ pub fn run() {
let value = store.get("some-key").expect("Failed to get value from store");
println!("{}", value); // {"value":5}
- // You can manually save the store after making changes.
- // Otherwise, it will save upon graceful exit as described above.
- store.save()?;
-
-
Ok(())
})
.run(tauri::generate_context!())
@@ -136,6 +128,32 @@ pub fn run() {
+## Migrating from v1 and v2 beta/rc
+
+
+
+
+
+```diff
+- import { Store } from '@tauri-apps/plugin-store';
++ import { LazyStore } from '@tauri-apps/plugin-store';
+```
+
+
+
+
+```diff
+- 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
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.