#tauri-plugin #widgets #android #timeline #preferences

sys tauri-plugin-widget

A Tauri plugin to interact with App Widgets (Android). Allows your Tauri app to shared preferences (Android), and update timeline widgets.

3 releases

0.1.2 Sep 29, 2025
0.1.1 Sep 28, 2025
0.1.0 Sep 28, 2025

#554 in GUI

Download history 308/week @ 2025-09-25 66/week @ 2025-10-02 11/week @ 2025-10-09 5/week @ 2025-10-16

53 downloads per month

MIT license

46KB
506 lines

📦 Tauri Plugin widget

A Tauri plugin to interact with App Widgets (Android). Allows your Tauri app to shared preferences (Android), and update timeline widgets.

Crates.io MIT licensed

[!NOTE]
Thanks for the idea from https://github.com/kisimediaDE/capacitor-widget-bridge

🎬 Demo

Android Example Demo

🚀 Install

  • Rust
[dependencies]
tauri-plugin-widget = "0.1.2"
  • Javascript (npm, pnpm yarn, ...)
npm install tauri-plugin-widget-api

📱 Setup

  • First, in src-tauri/lib.rs
pub fn run() {
    tauri::Builder::default()
        // Register here.
        .plugin(tauri_plugin_widget::init())
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
  • Next, in ui (react, svelte, vue, ...)
import {
  setItems,
  getItems,
  setRegisterWidget,
  reloadTimelines,
  requestWidget,
} from "tauri-plugin-widget-api";

[!IMPORTANT]
You always set register the widget classes in JS code await setRegisterWidget(["com.example.widgetbrideexample.MyWidget"]);

📖 Api

setItems(key: string, value: string, group: string): Promise<DataResult<boolean>>

Stores a key-value pair in the widget storage under a specific group.

  • key: The key under which the value will be stored.
  • value: The string value to store.
  • group: The namespace or group to organize stored items.

Returns:
Promise<DataResult<boolean>>true if the item was stored successfully.


getItems(key: string, group: string): Promise<DataResult<any>>

Retrieves a value from the widget storage based on key and group.

  • key: The key to retrieve.
  • group: The namespace containing the item.

Returns:
Promise<DataResult<any>> – The stored value (any type) or null if not found.


reloadAllTimelines(): Promise<DataResult<boolean>>

Requests the system to reload all widget timelines (refreshes every registered widget).

Returns:
Promise<DataResult<boolean>>true if the reload was successful.


reloadTimelines(ofKind: string): Promise<DataResult<boolean>>

Requests the system to reload timelines of a specific kind of widget.

  • ofKind: The widget/timeline type to reload.

Returns:
Promise<DataResult<boolean>>true if the reload was successful.


setRegisterWidget(widgets: string[]): Promise<DataResult<boolean>>

Registers a list of widgets that the application will manage.

  • widgets: An array of widget identifiers or names.

Returns:
Promise<DataResult<boolean>>true if registration was successful.


requestWidget(): Promise<DataResult<boolean>>

Requests the system to provide or display the registered widget.
(Useful for triggering the widget add flow on the home screen).

Returns:
Promise<DataResult<boolean>>true if the request was successful.

📱 Platform

  • This plugin only support android.
  • You can contribute an IOS version to it.

🪪 License

MIT

Dependencies

~16–61MB
~855K SLoC