Skip to content

How to use โ€” usePluginApi() โ€‹

In any plugin Vue setup() (typically your *Widget.vue), call:

typescript
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 inside setup().
  • 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.

typescript
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 โ€‹

typescript
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:

typescript
const { $data, $socket, $i18n } = usePluginApi("pacifico__example-todo")

You get a limited API surface:

IncludedNot included on foreign plugin
$data, $socket, $i18n, $log, $user, $eventbus$store widget helpers
Custom keys from that pluginโ€™s installSibling-widget helpers tied to your widget instance

Backend-side cross-plugin calls use plugin contracts.

Options object โ€‹

typescript
usePluginApi({ pluginKey: "author__other", actionId: "my-stable-id" })

Use actionId when you need stable query-cache identity for $data.

See also โ€‹