Skip to content

A Tauri application that implements global state management. The local state for individual frontend windows is managed using Zustand, a small, fast, and scalable state-management solution. The global state, on the other hand, is managed in the Rust backend and is synchronized across all frontend windows.

License

Notifications You must be signed in to change notification settings

robosushie/tauri-global-state-management

Repository files navigation

Tauri Global State Management

A Tauri application with global state management. The local state for individual frontend windows is managed using Zustand, while the global state is managed and synced across all frontend windows using the Rust backend.

Project Structure

Project Root
├── scripts
│   └── generate-macros.py
├── src
│   ├── assets
│   ├── constants
│   │   ├── events.ts
│   │   ├── global.ts
│   │   └── index.ts
│   ├── states
│   │   └── global-state.ts
│   ├── types
│   │   └── state.ts
│   ├── App.tsx
│   ├── App.css
│   ├── main.tsx
│   ├── styles.css
│   └── vite-env.d.ts
├── src-tauri
│   ├── src
│   │   ├── autogen
│   │   │   └── constants.rs
│   │   ├── states
│   │   │   └── states.rs
│   │   └── main.rs
│   └── ... other files and folders
└── ... other files and folders

Installation

Clone the repository:

git clone https://github.com/robosushie/tauri-global-state-management.git

Navigate into the project directory:

cd tauri-global-state-management

Install the dependencies:

pnpm install

Generate the Rust constants and enums:

pnpm run autogen

Usage

Start the Tauri application in development mode:

pnpm run dev

You can interact with the frontend by clicking the increment, decrement, and toggle buttons. The global state should be updated and synced across all frontend windows.

Future Roadmap

  • Add a STATE_FETCH event to fetch the state when different frontend windows come up at different times. This will also be useful when a webview window comes up after a crash.

  • Convert this into a single plugin with most of the backend state management code written with autogeneration.

License

This project is licensed under the MIT License.

About

A Tauri application that implements global state management. The local state for individual frontend windows is managed using Zustand, a small, fast, and scalable state-management solution. The global state, on the other hand, is managed in the Rust backend and is synchronized across all frontend windows.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published