📦 Tauri Plugin widget
A Tauri plugin to interact with App Widgets (Android). Allows your Tauri app to shared preferences (Android), and update timeline widgets.
[!NOTE]
Thanks for the idea from https://github.com/kisimediaDE/capacitor-widget-bridge
🎬 Demo
🚀 Install
- Rust
[]
= "0.1.2"
- Javascript (npm, pnpm yarn, ...)
📱 Setup
- First, in
src-tauri/lib.rs
- Next, in
ui (react, svelte, vue, ...)
import 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