How to use โ usePluginApi() โ
In any plugin Vue setup() (typically your *Widget.vue), call:
const { $data, $store, $i18n, $socket, $log, $user } = usePluginApi()That is the normal way to reach your pluginโs runtime API. Deeper API options live in the FAQ guides; this page covers what you need in widgets day to day.
Requirements โ
- Call
usePluginApi()only insidesetup(). - The component must belong to a registered plugin (the build injects the plugin key).
$data โ
Operations usually come from frontend/generated-config.ts (when you have a backend). You can also declare operations in frontend/index.ts โ see Consuming generated-config.
const { $data } = usePluginApi()
const { data, execute, isLoading, error } = $data.todo.getAll({
options: { immediate: true },
})$store โ
Widget and UI helpers (your plugin only):
getWidgetState, updateWidgetState, updateConfig, updatePublic, publishWorkingState, getSiblingWidgetStates, getUiState, โฆ
$socket and $eventbus โ
Use the channel keys from generated-config (or your manual data definitions) so lists update after mutations.
$i18n and $log โ
const { $i18n, $log } = usePluginApi()
const title = $i18n.t("myPlugin.title")
$log.info("loaded")Another plugin: usePluginApi('author__plugin') โ
To call a different pluginโs generated operations:
const { $data, $socket, $i18n } = usePluginApi("pacifico__example-todo")You get a limited API surface:
| Included | Not included on foreign plugin |
|---|---|
$data, $socket, $i18n, $log, $user, $eventbus | $store widget helpers |
Custom keys from that pluginโs install | Sibling-widget helpers tied to your widget instance |
Backend-side cross-plugin calls use plugin contracts.
Options object โ
usePluginApi({ pluginKey: "author__other", actionId: "my-stable-id" })Use actionId when you need stable query-cache identity for $data.
See also โ
- Widgets
- Reading & writing URL state (advanced)