---
title: JavaScript API
---
# JavaScript API
Package: `tauri-plugin-widgets-api`. Types for the widget IR are generated from Rust (`guest-js/generated/widget-types.ts`) — do not hand-edit them.
<div class="doc-illust">

</div>
```ts
import {
setWidgetConfig,
createWidgetWindow,
onWidgetAction,
startWidgetUpdater,
} from "tauri-plugin-widgets-api";
```
## Config and storage
| `setWidgetConfig(config, group, widgetId, skipReload?)` | Push a full `WidgetConfig`. Returns `ApplyOutcome` (`written`, `reload`, `transports`, optional `skip`) — not a bare boolean |
| `getWidgetTrace(group, { since? })` | Host delivery journal + receipt history (debug / `WIDGET_DEBUG=1`) |
| `flushWidgetTrace()` | Flush journal to disk (desktop) |
| `getWidgetConfig(group, widgetId)` | Read the stored config |
| `setItems(key, value, group)` | Low-level key/value write shared with native widgets |
| `getItems(key, group)` | Low-level key/value read |
## Timelines and Android pin
| `reloadAllTimelines()` | Ask the host to reload widget timelines |
| `reloadTimelines(ofKind)` | Reload a specific widget kind |
| `setRegisterWidget(widgets)` | Register provider class names (Android) |
| `requestWidget()` | Prompt the user to pin a widget (Android) |
## Desktop windows
| `createWidgetWindow(config)` | Frameless transparent window; pass `group`, `widgetId`, `size` for the built-in renderer |
| `closeWidgetWindow(label)` | Close a window created earlier |
```ts
await createWidgetWindow({
label: "weather",
width: 280,
height: 160,
group: "group.com.example.myapp",
widgetId: "weather",
size: "small",
});
```
## Actions
| `widgetAction(action, payload?, opts?)` | Emit a `widget-action` from the host |
| `onWidgetAction(callback)` | Subscribe to taps from `button` / `link` / list rows |
| `pollPendingWidgetActions(group)` | Drain native-queued actions (Android fallback) |
Action payload: `{ action, payload?, ts, widgetId, group }`.
## Diagnostics
| `reportReceipt(receipt)` | Native renderers report what they drew / skipped |
| `getWidgetDiagnostics(group)` | Inspect latest receipts for a group |
## Updater
| `startWidgetUpdater(builder, group, widgetId, options?)` | Periodically rebuild and push config; returns a `stop` function |
See [Updating data](/guide/recipes/updating-data) for WidgetKit reload budget notes.
## Rust
Host-side API: [Rust API](/api/rust) · [docs.rs](https://docs.rs/tauri-plugin-widgets/).