Skip to content
Tauri

State Management

Contribute

This is a stub and is waiting for contributions. Get involved by visiting us on GitHub or joining us on Discord.

Here are some ideas to get you started:

Define a state struct and let Tauri manage it:

use std::{collections::HashMap, sync::Mutex};
use tauri::{Manager, plugin::Builder};
#[derive(Default)]
struct Store(Mutex<HashMap<usize, String>>);
Builder::new("<plugin-name>")
.setup(|app, api| {
app.manage(Store::default());
// retrieve the store later
let store = app.state::<Store>();
Ok(())
})

© 2024 Tauri Contributors. CC-BY / MIT