Skip to content
Tauri
Releases

Store

Simple, persistent key-value store.

  • 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 store

import { Store } from '@tauri-apps/plugin-store';
// Store will be loaded automatically when used in JavaScript binding.
const store = new Store('store.bin');
// Set a value.
await store.set('some-key', { value: 5 });
// Get a value.
const val = await store.get('some-key');
console.log(val); // { value: 5 }
// You can manually save the store after making changes.
// Otherwise, it will save upon graceful exit as described above.
await store.save();

By default, all plugin commands are blocked and cannot be accessed. You must define a list of permissions in your capabilities configuration.

See Access Control List for more information.

src-tauri/capabilities/main.json
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "main-capability",
"description": "Capability for the main window",
"windows": ["main"],
"permissions": [
"store:allow-get",
"store:allow-set",
"store:allow-save",
"store:allow-load"
]
}
PermissionDescription
store:allow-clearEnables the clear command without any pre-configured scope.
store:deny-clearDenies the clear command without any pre-configured scope.
store:allow-deleteEnables the delete command without any pre-configured scope.
store:deny-deleteDenies the delete command without any pre-configured scope.
store:allow-entriesEnables the entries command without any pre-configured scope.
store:deny-entriesDenies the entries command without any pre-configured scope.
store:allow-getEnables the get command without any pre-configured scope.
store:deny-getDenies the get command without any pre-configured scope.
store:allow-hasEnables the has command without any pre-configured scope.
store:deny-hasDenies the has command without any pre-configured scope.
store:allow-keysEnables the keys command without any pre-configured scope.
store:deny-keysDenies the keys command without any pre-configured scope.
store:allow-lengthEnables the length command without any pre-configured scope.
store:deny-lengthDenies the length command without any pre-configured scope.
store:allow-loadEnables the load command without any pre-configured scope.
store:deny-loadDenies the load command without any pre-configured scope.
store:allow-resetEnables the reset command without any pre-configured scope.
store:deny-resetDenies the reset command without any pre-configured scope.
store:allow-saveEnables the save command without any pre-configured scope.
store:deny-saveDenies the save command without any pre-configured scope.
store:allow-setEnables the set command without any pre-configured scope.
store:deny-setDenies the set command without any pre-configured scope.
store:allow-valuesEnables the values command without any pre-configured scope.
store:deny-valuesDenies the values command without any pre-configured scope.

© 2024 Tauri Contributors. CC-BY / MIT