Persist App State to Disk in Tauri 2 | Store Plugin Tutorial

Codegiz — Built by Claude AI · Beginner ·🛠️ AI Tools & Apps ·2mo ago

About this lesson

Make your Tauri 2 app remember things across restarts. tauri-plugin-store gives you a tiny key-value store that writes JSON to the OS app data directory — no schema, no migrations, no boilerplate. Set a value, restart the app, the value is still there. Source code: https://github.com/GoCelesteAI/tauri_persisto We build Persisto, a minimal counter that survives every relaunch: increment, decrement, reset — quit the app, reopen it, the count is exactly where you left it. The whole thing is one App.tsx, one Rust plugin registration, one capability entry. What You'll Learn: - tauri-plugin-store — install on both the Rust side (Cargo) and the JS side (pnpm) and register the plugin in lib.rs. - load("counter.json", { autoSave: true }) — opens (or creates) the store file at the platform-correct path. autoSave writes through on every change so you don't have to call save() manually. - store.set(key, value) and typed store.get — typed key-value reads and writes. Values are JSON, so any serializable type works. - The platform store path — macOS Application Support, Linux ~/.local/share, Windows %APPDATA% — each scoped to your bundle identifier. Tauri resolves it from the identifier in tauri.conf.json. - Capability gating — store:default is the permission your capabilities/default.json needs. Without it, the JS load() call errors at runtime. - The load-then-render pattern — call load() once in useEffect, seed React state from store.get, and write back on every change. Pattern works for any "remember the last X" requirement. Timestamps: 0:00 - The proof: increment, quit, relaunch, still there 0:25 - Capability config — store:default 0:50 - Register tauri-plugin-store in lib.rs 1:20 - App.tsx — load the store, read on mount, write on change 3:30 - Run it — the counter that survives restarts 4:15 - End screen Key Takeaways: 1. tauri-plugin-store is the right default for app state. For settings, preferences, last-opened-file paths, window geometry, anything that fits in a fl

Original Description

Make your Tauri 2 app remember things across restarts. tauri-plugin-store gives you a tiny key-value store that writes JSON to the OS app data directory — no schema, no migrations, no boilerplate. Set a value, restart the app, the value is still there. Source code: https://github.com/GoCelesteAI/tauri_persisto We build Persisto, a minimal counter that survives every relaunch: increment, decrement, reset — quit the app, reopen it, the count is exactly where you left it. The whole thing is one App.tsx, one Rust plugin registration, one capability entry. What You'll Learn: - tauri-plugin-store — install on both the Rust side (Cargo) and the JS side (pnpm) and register the plugin in lib.rs. - load("counter.json", { autoSave: true }) — opens (or creates) the store file at the platform-correct path. autoSave writes through on every change so you don't have to call save() manually. - store.set(key, value) and typed store.get — typed key-value reads and writes. Values are JSON, so any serializable type works. - The platform store path — macOS Application Support, Linux ~/.local/share, Windows %APPDATA% — each scoped to your bundle identifier. Tauri resolves it from the identifier in tauri.conf.json. - Capability gating — store:default is the permission your capabilities/default.json needs. Without it, the JS load() call errors at runtime. - The load-then-render pattern — call load() once in useEffect, seed React state from store.get, and write back on every change. Pattern works for any "remember the last X" requirement. Timestamps: 0:00 - The proof: increment, quit, relaunch, still there 0:25 - Capability config — store:default 0:50 - Register tauri-plugin-store in lib.rs 1:20 - App.tsx — load the store, read on mount, write on change 3:30 - Run it — the counter that survives restarts 4:15 - End screen Key Takeaways: 1. tauri-plugin-store is the right default for app state. For settings, preferences, last-opened-file paths, window geometry, anything that fits in a fl
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Related Reads

📰
Three Token-2022 Mints in One Week: Fees, Yield, and Soulbound
Learn how to build three different Token-2022 mints on Solana devnet in one week, including fee-bearing, interest-accruing, and soulbound tokens
Dev.to · atharv shukla
📰
Maximize Google Workspace AI Power: Safeguard Data and Boost Performance in 2026
Maximize Google Workspace AI power by safeguarding data and boosting performance to stay ahead in 2026
Dev.to AI
📰
What is Gemini Spark, and what can it actually do for you?
Gemini Spark integrates AI into daily Google apps to enhance productivity, learn how to leverage it
TechCabal
📰
How I use python to save hours every week
Learn how to use Python to automate tasks and save hours every week, with practical steps for beginners and experienced users alike.
Dev.to AI

Chapters (6)

The proof: increment, quit, relaunch, still there
0:25 Capability config — store:default
0:50 Register tauri-plugin-store in lib.rs
1:20 App.tsx — load the store, read on mount, write on change
3:30 Run it — the counter that survives restarts
4:15 End screen
Up next
Implement Microsoft Entra ID Auth with Delegated Graph API Calls in ASP.NET Core Web App Razor Pages
Dewiride Technologies
Watch →