Write your own Context API

Provide your own Context, to enable communication across extensions
A Context is an instance of a class that is provided with the Context API.
To give your Context API power and encapsulate the execution you should base your Context API on an Umbraco Controller. Read more about Controllers here
Notice how you can provide a Global Context API via the GlobalContext Extension Type.


The following example shows how to write a self-providing Context:
import { UmbBaseController, type UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
export const MY_OWN_CONTEXT = new UmbContextToken<MyOwnContext>('my-own-context')
class MyOwnContext extends UmbBaseController {
constructor(host: UmbControllerHost) {
this.provideContext('umbPropertyActionMenu', this);
Example of an element that instantiates your Context, for it self or any descending elements or Controllers to consume:
export class MyElement extends UmbElementMixin(LitElement) {
constructor() {
new MyOwnContext(this);