API

Tauri commands

Every Tauri command of the plugin with its arguments, generated from src/commands.rs.

The #[tauri::command] functions in src/commands.rs, which the JS package calls with invoke('plugin:widgets|<name>', args). You normally use the JS functions instead; this list is for calling commands directly. Arguments are sent in camelCase; AppHandle and State parameters are injected by Tauri and not listed. Rust-side API: Rust.

CommandDescription
set_itemsStore a key-value pair in the widget data store.
get_itemsRead a previously stored value from the widget data store.
set_register_widgetRegister widget provider class names or kind strings.
reload_all_timelinesReload all registered widget timelines.
reload_timelinesReload timelines for a specific widget kind or class.
request_widgetRequest the OS to pin (add) a widget to the home screen.
create_widget_windowCreate a frameless, transparent desktop widget window.
close_widget_windowClose a previously created desktop widget window.
set_widget_configSend a declarative UI configuration to native widgets.
set_widget_config_from_pathLoad a WidgetConfig JSON file from disk, then apply it like set_widget_config.
get_widget_configRead the current widget UI configuration from the data store.
set_widget_dataValues for {{data.…}} without resending the layout. null clears them.
set_widget_stateChange a placement's local state ({{state.…}}) like a set tap does: operators $toggle / $inc / $dec, null removes a key, patch: null clears the stored state. Returns the merged state (defaults included) and emits widget-state-changed.
get_widget_stateA placement's merged local state: config state defaults, then the stored state.
register_activity_templateStore a Live Activity layout under name (activity-template:{name}): activities with template: name then send only data. null removes it.
set_widget_instancesChoices for the per-placement picker (Apple Edit Widget sheet; listed for Android and desktop so the app can label placements).
get_active_widgetsWidgets placed right now (see ActiveWidget).
start_activityStart (or update, when the id runs) a live activity.
update_activityReplace the content of a running live activity.
end_activityEnd a live activity; dismissAfterMs keeps the final state visible that long (iOS / desktop; Android removes the notification at once). content is the final state; dismissalPolicy "default" | "immediate" (dismissAfterMs wins).
get_widget_push_tokenWidgetKit push token (hex) for server-driven widget reloads; null where none exists.
get_activity_push_to_start_tokeniOS 17.2+ push-to-start token (hex) for your APNs server; null elsewhere / not yet issued.
can_promote_activitiesAndroid 16+: whether ongoing activity notifications may be promoted to Live Updates (status-bar chip, lock screen). true where the question does not apply.
open_activity_promotion_settingsAndroid: opens the system setting that allows Live Updates for this app. false when there is no such screen (other platforms, older Android).
list_activitiesIds of the running live activities this app started.
activity_islandDesktop activity island page → host: expanded grows / shrinks the island (hover, click), focus brings a minimal activity to the pill. Returns what the island shows (null on mobile or without an island). Used by the built-in renderer.
widget_actionTrigger a widget-action event via the Rust plugin.
poll_pending_actions
report_receiptReport that a renderer painted a config (desktop widget.html / tests). Native widgets write receipts themselves; this is for the host webview path.
get_widget_diagnosticsLive widget instances that recently rendered for group.
get_widget_traceHost delivery journal + receipt history for group. Active in debug builds or when WIDGET_DEBUG=1.
flush_widget_traceForce-flush the in-memory journal to disk (desktop).

Commands

set_items

Store a key-value pair in the widget data store.

invoke('plugin:widgets|set_items', { key, value, group })
Argument (JS)Rust parameterType
keykeyString
valuevalueString
groupgroupOption<String>

Returns bool. Rust: async fn. Permission: widgets:allow-set-items. JS wrapper: setItems().

get_items

Read a previously stored value from the widget data store.

invoke('plugin:widgets|get_items', { key, group })
Argument (JS)Rust parameterType
keykeyString
groupgroupOption<String>

Returns Option<String>. Rust: async fn. Permission: widgets:allow-get-items. JS wrapper: getItems().

set_register_widget

Register widget provider class names or kind strings.

invoke('plugin:widgets|set_register_widget', { widgets })
Argument (JS)Rust parameterType
widgetswidgetsVec<String>

Returns bool. Rust: plain (sync) fn. Permission: widgets:allow-set-register-widget. JS wrapper: setRegisterWidget().

reload_all_timelines

Reload all registered widget timelines.

invoke('plugin:widgets|reload_all_timelines')

No arguments.

Returns bool. Rust: plain (sync) fn. Permission: widgets:allow-reload-all-timelines. JS wrapper: reloadAllTimelines().

reload_timelines

Reload timelines for a specific widget kind or class.

invoke('plugin:widgets|reload_timelines', { ofKind })
Argument (JS)Rust parameterType
ofKindof_kindString

Returns bool. Rust: plain (sync) fn. Permission: widgets:allow-reload-timelines. JS wrapper: reloadTimelines().

request_widget

Request the OS to pin (add) a widget to the home screen.

invoke('plugin:widgets|request_widget')

No arguments.

Returns bool. Rust: plain (sync) fn. Permission: widgets:allow-request-widget. JS wrapper: requestWidget().

create_widget_window

Create a frameless, transparent desktop widget window.

invoke('plugin:widgets|create_widget_window', { mut config })
Argument (JS)Rust parameterType
mut configmut configWidgetWindowConfig

Returns bool. Rust: async fn. Permission: widgets:allow-create-widget-window. JS wrapper: createWidgetWindow().

close_widget_window

Close a previously created desktop widget window.

invoke('plugin:widgets|close_widget_window', { label })
Argument (JS)Rust parameterType
labellabelString

Returns bool. Rust: async fn. Permission: widgets:allow-close-widget-window. JS wrapper: closeWidgetWindow().

set_widget_config

Send a declarative UI configuration to native widgets.

invoke('plugin:widgets|set_widget_config', { config, group, widgetId, skipReload, instance })
Argument (JS)Rust parameterType
configconfigWidgetConfig
groupgroupOption<String>
widgetIdwidget_idString
skipReloadskip_reloadOption<bool>
instanceinstanceOption<String>

Returns ApplyOutcome. Rust: async fn. Permission: widgets:allow-set-widget-config. JS wrapper: setWidgetConfig().

set_widget_config_from_path

Load a WidgetConfig JSON file from disk, then apply it like set_widget_config.

path must be readable by the app process (absolute path or resolved resource / app-data path). Network URLs are not supported.

invoke('plugin:widgets|set_widget_config_from_path', { path, group, widgetId, skipReload, instance })
Argument (JS)Rust parameterType
pathpathString
groupgroupOption<String>
widgetIdwidget_idString
skipReloadskip_reloadOption<bool>
instanceinstanceOption<String>

Returns ApplyOutcome. Rust: async fn. Permission: widgets:allow-set-widget-config-from-path. JS wrapper: setWidgetConfigFromPath().

get_widget_config

Read the current widget UI configuration from the data store.

invoke('plugin:widgets|get_widget_config', { group, widgetId, instance })
Argument (JS)Rust parameterType
groupgroupOption<String>
widgetIdwidget_idString
instanceinstanceOption<String>

Returns Option<WidgetConfig>. Rust: async fn. Permission: widgets:allow-get-widget-config. JS wrapper: getWidgetConfig().

set_widget_data

Values for {{data.…}} without resending the layout. null clears them.

invoke('plugin:widgets|set_widget_data', { widgetId, data, instance, group, skipReload })
Argument (JS)Rust parameterType
widgetIdwidget_idString
datadataserde_json::Value
instanceinstanceOption<String>
groupgroupOption<String>
skipReloadskip_reloadOption<bool>

Returns bool. Rust: async fn. Permission: widgets:allow-set-widget-data. JS wrapper: setWidgetData().

set_widget_state

Change a placement's local state ({{state.…}}) like a set tap does: operators $toggle / $inc / $dec, null removes a key, patch: null clears the stored state. Returns the merged state (defaults included) and emits widget-state-changed.

invoke('plugin:widgets|set_widget_state', { widgetId, patch, instance, group, skipReload })
Argument (JS)Rust parameterType
widgetIdwidget_idString
patchpatchserde_json::Value
instanceinstanceOption<String>
groupgroupOption<String>
skipReloadskip_reloadOption<bool>

Returns serde_json::Value. Rust: async fn. Permission: widgets:allow-set-widget-state. JS wrapper: setWidgetState().

get_widget_state

A placement's merged local state: config state defaults, then the stored state.

invoke('plugin:widgets|get_widget_state', { widgetId, instance, group })
Argument (JS)Rust parameterType
widgetIdwidget_idString
instanceinstanceOption<String>
groupgroupOption<String>

Returns serde_json::Value. Rust: async fn. Permission: widgets:allow-get-widget-state. JS wrapper: getWidgetState().

register_activity_template

Store a Live Activity layout under name (activity-template:{name}): activities with template: name then send only data. null removes it.

invoke('plugin:widgets|register_activity_template', { name, layout, group })
Argument (JS)Rust parameterType
namenameString
layoutlayoutserde_json::Value
groupgroupOption<String>

Returns bool. Rust: async fn. Permission: widgets:allow-register-activity-template. JS wrapper: registerActivityTemplate().

set_widget_instances

Choices for the per-placement picker (Apple Edit Widget sheet; listed for Android and desktop so the app can label placements).

invoke('plugin:widgets|set_widget_instances', { widgetId, instances, group })
Argument (JS)Rust parameterType
widgetIdwidget_idString
instancesinstancesVec<WidgetInstanceOption>
groupgroupOption<String>

Returns bool. Rust: async fn. Permission: widgets:allow-set-widget-instances. JS wrapper: setWidgetInstances().

get_active_widgets

Widgets placed right now (see ActiveWidget).

invoke('plugin:widgets|get_active_widgets', { group })
Argument (JS)Rust parameterType
groupgroupOption<String>

Returns Vec<ActiveWidget>. Rust: async fn. Permission: widgets:allow-get-active-widgets. JS wrapper: getActiveWidgets().

start_activity

Start (or update, when the id runs) a live activity.

invoke('plugin:widgets|start_activity', { content, group })
Argument (JS)Rust parameterType
contentcontentActivityContent
groupgroupOption<String>

Returns ActivityHandle. Rust: async fn. Permission: widgets:allow-start-activity. JS wrapper: startActivity().

update_activity

Replace the content of a running live activity.

invoke('plugin:widgets|update_activity', { content, group })
Argument (JS)Rust parameterType
contentcontentActivityContent
groupgroupOption<String>

Returns bool. Rust: async fn. Permission: widgets:allow-update-activity. JS wrapper: updateActivity().

end_activity

End a live activity; dismissAfterMs keeps the final state visible that long (iOS / desktop; Android removes the notification at once). content is the final state; dismissalPolicy "default" | "immediate" (dismissAfterMs wins).

invoke('plugin:widgets|end_activity', { id, dismissAfterMs, content, dismissalPolicy, group })
Argument (JS)Rust parameterType
ididString
dismissAfterMsdismiss_after_msOption<u64>
contentcontentOption<ActivityContent>
dismissalPolicydismissal_policyOption<String>
groupgroupOption<String>

Returns bool. Rust: async fn. Permission: widgets:allow-end-activity. JS wrapper: endActivity().

get_widget_push_token

WidgetKit push token (hex) for server-driven widget reloads; null where none exists.

invoke('plugin:widgets|get_widget_push_token', { group })
Argument (JS)Rust parameterType
groupgroupOption<String>

Returns Option<String>. Rust: async fn. Permission: widgets:allow-get-widget-push-token. JS wrapper: getWidgetPushToken().

get_activity_push_to_start_token

iOS 17.2+ push-to-start token (hex) for your APNs server; null elsewhere / not yet issued.

invoke('plugin:widgets|get_activity_push_to_start_token')

No arguments.

Returns Option<String>. Rust: async fn. Permission: widgets:allow-get-activity-push-to-start-token. JS wrapper: getActivityPushToStartToken().

can_promote_activities

Android 16+: whether ongoing activity notifications may be promoted to Live Updates (status-bar chip, lock screen). true where the question does not apply.

invoke('plugin:widgets|can_promote_activities')

No arguments.

Returns bool. Rust: async fn. Permission: widgets:allow-can-promote-activities. JS wrapper: canPromoteActivities().

open_activity_promotion_settings

Android: opens the system setting that allows Live Updates for this app. false when there is no such screen (other platforms, older Android).

invoke('plugin:widgets|open_activity_promotion_settings')

No arguments.

Returns bool. Rust: async fn. Permission: widgets:allow-open-activity-promotion-settings. JS wrapper: openActivityPromotionSettings().

list_activities

Ids of the running live activities this app started.

invoke('plugin:widgets|list_activities')

No arguments.

Returns Vec<String>. Rust: async fn. Permission: widgets:allow-list-activities. JS wrapper: listActivities().

activity_island

Desktop activity island page → host: expanded grows / shrinks the island (hover, click), focus brings a minimal activity to the pill. Returns what the island shows (null on mobile or without an island). Used by the built-in renderer.

invoke('plugin:widgets|activity_island', { expanded, focus })
Argument (JS)Rust parameterType
expandedexpandedOption<bool>
focusfocusOption<String>

Returns Option<serde_json::Value>. Rust: async fn. Permission: widgets:allow-activity-island.

widget_action

Trigger a widget-action event via the Rust plugin.

invoke('plugin:widgets|widget_action', { action, payload, widgetId, group })
Argument (JS)Rust parameterType
actionactionString
payloadpayloadOption<String>
widgetIdwidget_idOption<String>
groupgroupOption<String>

Returns bool. Rust: plain (sync) fn. Permission: widgets:allow-widget-action. JS wrapper: widgetAction().

poll_pending_actions

invoke('plugin:widgets|poll_pending_actions', { group })
Argument (JS)Rust parameterType
groupgroupOption<String>

Returns Vec<crate::WidgetActionEnvelope>. Rust: async fn. Permission: widgets:allow-poll-pending-actions.

report_receipt

Report that a renderer painted a config (desktop widget.html / tests). Native widgets write receipts themselves; this is for the host webview path.

invoke('plugin:widgets|report_receipt', { mut receipt })
Argument (JS)Rust parameterType
mut receiptmut receiptcrate::receipt::WidgetRenderReceipt

Returns bool. Rust: plain (sync) fn. Permission: widgets:allow-report-receipt. JS wrapper: reportReceipt().

get_widget_diagnostics

Live widget instances that recently rendered for group.

invoke('plugin:widgets|get_widget_diagnostics', { group })
Argument (JS)Rust parameterType
groupgroupOption<String>

Returns Vec<crate::receipt::WidgetRenderReceipt>. Rust: plain (sync) fn. Permission: widgets:allow-get-widget-diagnostics. JS wrapper: getWidgetDiagnostics().

get_widget_trace

Host delivery journal + receipt history for group. Active in debug builds or when WIDGET_DEBUG=1.

invoke('plugin:widgets|get_widget_trace', { group, sinceMs })
Argument (JS)Rust parameterType
groupgroupOption<String>
sinceMssince_msOption<u64>

Returns crate::trace::WidgetTrace. Rust: plain (sync) fn. Permission: widgets:allow-get-widget-trace. JS wrapper: getWidgetTrace().

flush_widget_trace

Force-flush the in-memory journal to disk (desktop).

invoke('plugin:widgets|flush_widget_trace')

No arguments.

Returns bool. Rust: plain (sync) fn. Permission: widgets:allow-flush-widget-trace. JS wrapper: flushWidgetTrace().