https://github.com/ferreira-tb/tauri-store
Persistent stores for Tauri
https://github.com/ferreira-tb/tauri-store
nuxt pinia react svelte tauri vue
Last synced: 2 months ago
JSON representation
Persistent stores for Tauri
- Host: GitHub
- URL: https://github.com/ferreira-tb/tauri-store
- Owner: ferreira-tb
- License: mit
- Created: 2024-07-05T00:17:44.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-03-28T23:49:16.000Z (3 months ago)
- Last Synced: 2025-03-31T05:02:23.509Z (3 months ago)
- Topics: nuxt, pinia, react, svelte, tauri, vue
- Language: Rust
- Homepage: https://tb.dev.br/tauri-store/
- Size: 2.21 MB
- Stars: 46
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# tauri-store
Persistent stores for Tauri.
## Features
- Save your stores to disk.
- Synchronize across multiple windows.
- Debounce or throttle store updates.
- Access the stores from both JavaScript and Rust.## Usage
```typescript
import { Store } from 'tauri-store';const store = new Store('my-store', { counter: 0 });
// Get a value. This is a synchronous operation!
const counter = store.get('counter');
console.log(counter);// Set a value.
store.set('counter', 42);// Update a value with a callback.
store.update('counter', (value) => value + 1);// Set multiple values at once.
store.patch({ counter: 0 });// Listen to changes.
store.subscribe((state) => {
console.log(state);
});// Save the store. Unlike the others, this is asynchronous.
await store.save();
```> [!TIP]
> There are also [custom plugins](#plugins) that tightly integrate with your favorite framework or library.## Documentation
Check the [documentation](https://tb.dev.br/tauri-store/) for more information on how to install and use the plugins.
## Plugins
Currently, the following plugins are available:
| Name | Version | Works with |
| ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------- | ---------- |
| [tauri-store](https://tb.dev.br/tauri-store/guide/getting-started) | [](https://www.npmjs.com/package/tauri-store) | Everything |
| [@tauri-store/pinia](https://tb.dev.br/tauri-store/plugin-pinia/guide/getting-started) | [](https://www.npmjs.com/package/@tauri-store/pinia) | Vue, Nuxt |
| [@tauri-store/svelte](https://tb.dev.br/tauri-store/plugin-svelte/guide/getting-started) | [](https://www.npmjs.com/package/@tauri-store/svelte) | Svelte |
| [@tauri-store/valtio](https://tb.dev.br/tauri-store/plugin-valtio/guide/getting-started) | [](https://www.npmjs.com/package/@tauri-store/valtio) | React |
| [@tauri-store/zustand](https://tb.dev.br/tauri-store/plugin-zustand/guide/getting-started) | [](https://www.npmjs.com/package/@tauri-store/zustand) | React |## Examples
You can find example projects in the [examples directory](https://github.com/ferreira-tb/tauri-store/tree/main/examples). To check them out, run the following commands:
```sh
git clone https://github.com/ferreira-tb/tauri-store.git
cd tauri-store
pnpm install
pnpm run example [EXAMPLE_NAME]
```For example, to run the [`pinia`](https://github.com/ferreira-tb/tauri-store/tree/main/examples/pinia) project, you can use:
```sh
pnpm run example pinia
```For a completely random example, run:
```sh
pnpm run example random
```## Supported Tauri Version
The plugins require Tauri `2.0` or later.