Skip to content

Getting Started

Terminal window
bun add @capgo/capacitor-widget-kit
bunx cap sync
import { CapgoWidgetKit } from '@capgo/capacitor-widget-kit';

Check whether the native template activity bridge can run on the current device.

import { CapgoWidgetKit } from '@capgo/capacitor-widget-kit';
await CapgoWidgetKit.areActivitiesSupported();

Persist a generic SVG template activity and start the matching native Live Activity bridge.

import { CapgoWidgetKit } from '@capgo/capacitor-widget-kit';
await CapgoWidgetKit.startTemplateActivity({} as StartTemplateActivityOptions);

Replace part or all of the stored activity definition/state.

import { CapgoWidgetKit } from '@capgo/capacitor-widget-kit';
await CapgoWidgetKit.updateTemplateActivity({} as UpdateTemplateActivityOptions);

End a running activity while optionally persisting one last state snapshot.

import { CapgoWidgetKit } from '@capgo/capacitor-widget-kit';
await CapgoWidgetKit.endTemplateActivity({} as EndTemplateActivityOptions);

Execute one declarative action and record the resulting event.

import { CapgoWidgetKit } from '@capgo/capacitor-widget-kit';
await CapgoWidgetKit.performTemplateAction({} as PerformTemplateActionOptions);

Read one activity back from the shared store.

import { CapgoWidgetKit } from '@capgo/capacitor-widget-kit';
await CapgoWidgetKit.getTemplateActivity({} as GetTemplateActivityOptions);

List every activity currently known by the plugin.

import { CapgoWidgetKit } from '@capgo/capacitor-widget-kit';
await CapgoWidgetKit.listTemplateActivities();

List stored action events so the app can react to widget interactions later.

import { CapgoWidgetKit } from '@capgo/capacitor-widget-kit';
await CapgoWidgetKit.listTemplateEvents();

Mark previously processed events as acknowledged.

import { CapgoWidgetKit } from '@capgo/capacitor-widget-kit';
await CapgoWidgetKit.acknowledgeTemplateEvents({} as AcknowledgeTemplateEventsOptions);

Result of a Live Activities capability check.

export interface ActivitiesSupportedResult {
/**
* Whether the current device and runtime can run the native template activity bridge.
*/
supported: boolean;
/**
* Human-readable reason when support is unavailable.
*/
reason?: string;
}

Options for starting a generic SVG template activity.

export interface StartTemplateActivityOptions {
/**
* Optional explicit activity identifier. When omitted, the native runtime creates one.
*/
activityId?: string;
/**
* Generic SVG template definition.
*/
definition: SvgTemplateDefinition;
/**
* Initial JSON state exposed under `state.*`.
*/
state: SvgTemplateState;
/**
* Optional deep link used when the widget body is tapped.
*/
openUrl?: string;
}

Result when starting a generic template activity.

export interface StartTemplateActivityResult {
/**
* Stored activity snapshot.
*/
activity: SvgTemplateActivityRecord;
}

Options for updating an existing template activity.

export interface UpdateTemplateActivityOptions {
/**
* Activity identifier returned by `startTemplateActivity`.
*/
activityId: string;
/**
* Optional replacement definition.
*/
definition?: SvgTemplateDefinition;
/**
* Optional replacement state.
*/
state?: SvgTemplateState;
/**
* Optional replacement deep link.
*/
openUrl?: string;
}

Result when reading or updating a single activity.

export interface TemplateActivityResult {
/**
* Stored activity snapshot, or `null` when not found.
*/
activity: SvgTemplateActivityRecord | null;
}

Options for ending a template activity.

export interface EndTemplateActivityOptions {
/**
* Activity identifier returned by `startTemplateActivity`.
*/
activityId: string;
/**
* Optional final state persisted before ending.
*/
state?: SvgTemplateState;
}

Options for executing a declarative action.

export interface PerformTemplateActionOptions {
/**
* Activity identifier returned by `startTemplateActivity`.
*/
activityId: string;
/**
* Action identifier declared in the template definition.
*/
actionId: string;
/**
* Optional source identifier, typically the hotspot id that triggered the action.
*/
sourceId?: string;
/**
* Optional payload stored with the emitted event and exposed to declarative patches under `{{action.payload.*}}`.
*/
payload?: JsonObject;
}

Result after executing an action.

export interface PerformTemplateActionResult {
/**
* Updated activity snapshot.
*/
activity: SvgTemplateActivityRecord;
/**
* Action event emitted by the runtime.
*/
event: SvgTemplateActionEvent;
}

Options for reading one stored activity.

export interface GetTemplateActivityOptions {
/**
* Activity identifier to load.
*/
activityId: string;
}

Result when listing stored activities.

export interface ListTemplateActivitiesResult {
/**
* Stored activity snapshots.
*/
activities: SvgTemplateActivityRecord[];
}

Options when listing action events.

export interface ListTemplateEventsOptions {
/**
* Optional activity filter.
*/
activityId?: string;
/**
* When true, only unacknowledged events are returned.
*/
unacknowledgedOnly?: boolean;
}

Result when listing action events.

export interface ListTemplateEventsResult {
/**
* Matching action events.
*/
events: SvgTemplateActionEvent[];
}

This page is generated from the plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.