| Crates.io | tauri-plugin-preferences |
| lib.rs | tauri-plugin-preferences |
| version | 0.1.0 |
| created_at | 2025-12-24 08:20:54.743915+00 |
| updated_at | 2025-12-24 08:20:54.743915+00 |
| description | A Tauri plugin that provides cross-platform preferences storage using native system APIs |
| homepage | https://github.com/ahonn/tauri-plugin-preferences |
| repository | https://github.com/ahonn/tauri-plugin-preferences |
| max_upload_size | |
| id | 2002882 |
| size | 165,422 |
A Tauri plugin that provides cross-platform preferences storage using native system APIs.
NSUserDefaults on macOS/iOS)| Platform | Backend | Status |
|---|---|---|
| macOS | NSUserDefaults |
✅ Supported |
| iOS | UserDefaults |
✅ Supported |
| Windows | Registry | 🚧 Planned |
| Linux | XDG Config | 🚧 Planned |
| Android | SharedPreferences | 🚧 Planned |
# src-tauri/Cargo.toml
[dependencies]
tauri-plugin-preferences = "0.1"
npm install tauri-plugin-preferences-api
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_preferences::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Add to src-tauri/capabilities/default.json:
{
"permissions": ["preferences:default"]
}
import { get, set, remove, has, clear } from 'tauri-plugin-preferences-api';
// Store a value (automatically serialized to JSON)
await set('user', { name: 'John', age: 30 });
// Retrieve a value (automatically deserialized)
const user = await get<{ name: string; age: number }>('user');
// Check if key exists
const exists = await has('user');
// Remove a key
await remove('user');
// Clear all preferences
await clear();
use tauri_plugin_preferences::PreferencesExt;
fn example(app: &tauri::AppHandle) {
let prefs = app.preferences();
// Get a value
let result = prefs.get(GetRequest { key: "user".into() });
// Set a value
prefs.set(SetRequest {
key: "user".into(),
value: r#"{"name":"John"}"#.into(),
});
}
| Method | Description |
|---|---|
get<T>(key) |
Get a value, returns null if not found |
set<T>(key, value) |
Store a value (JSON serialized) |
remove(key) |
Remove a value |
has(key) |
Check if key exists |
clear() |
Clear all preferences |
MIT