🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@zubridge/tauri

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zubridge/tauri

A streamlined state management library for Tauri applications using Zustand.

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source
zubridge hero image

Cross-platform state without boundaries: Zustand-inspired simplicity for Tauri

Why Zubridge?

tldr: I want to seamlessly interact with my Rust backend state using Zustand-inspired hooks.

Zustand provides a simple and effective state management pattern. In Tauri applications, managing state consistently between the Rust backend (where the authoritative state often resides) and multiple frontend windows can be complex.

Zubridge @zubridge/tauri simplifies this by providing hooks (useZubridgeStore, useZubridgeDispatch) that connect your frontend components to your Rust backend state, abstracting away the necessary Tauri command invocations and event listening.

How It Works

Zubridge creates a bridge between your Rust backend state and your frontend JavaScript. Your Rust backend holds the source of truth, while the frontend uses hooks to access and update this state.

  • Backend: Register the tauri-plugin-zubridge plugin with your app state
  • Backend: Implement the StateManager trait to handle state changes
  • Frontend: Initialize the bridge with @zubridge/tauri
  • Frontend: Access state with useZubridgeStore and dispatch actions with useZubridgeDispatch

Features

  • Simple State Management: Connect frontend components to Rust backend state using Zustand-like hooks
  • Standard Interface: Consistent pattern for dispatching actions and receiving updates
  • Type Safety: Strong typing for both Rust and TypeScript sides
  • Multi-Window Support: Automatic state synchronization across multiple windows
  • Minimal Boilerplate: Reduced code for state management through the official plugin
  • Frontend Flexibility: Works with React, other frontend frameworks, or vanilla JavaScript
  • Tauri Version Support: Compatible with both Tauri v1 and v2 APIs via dependency injection

Installation

Rust Backend

# Cargo.toml
[dependencies]
tauri-plugin-zubridge = "0.1.0"
serde = { version = "1.0", features = ["derive"] }

Frontend

# Using npm
npm install @zubridge/tauri @tauri-apps/api

Or use your dependency manager of choice, e.g. pnpm, yarn.

Quick Start

  • Define your application state and implement the StateManager trait in your Rust backend
  • Register the tauri-plugin-zubridge plugin in your Tauri application
  • Initialize the bridge in your frontend with initializeBridge({ invoke, listen })
  • Access state with useZubridgeStore and dispatch actions with useZubridgeDispatch

For detailed implementation examples, see our Getting Started Guide.

Documentation

For more detailed documentation, see:

Example Applications

Complete example applications demonstrating the use of @zubridge/tauri:

Direct Architecture

zubridge tauri direct architecture

Plugin Architecture

zubridge tauri plugin architecture

License

MIT

Keywords

zustand

FAQs

Package last updated on 13 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts