API reference
Design
addAudioTrackaddElementAtCursoraddElementAtPointaddNativeElementaddPagecreateRichtextRangeeditContentgetCurrentPageContextgetDefaultPageDimensionsgetDesignMetadatagetDesignTokeninitAppElementopenDesignoverlay.registerOnCanOpenrequestExportselection.registerOnChangesetCurrentPageBackgroundui.startDragToCursorui.startDragToPointui.startDrag
Intents: data
Intents: design
Platform
appProcessappProcess.broadcastMessageappProcess.currentappProcess.current.getInfoappProcess.current.requestCloseappProcess.current.setOnDisposeappProcess.requestCloseappProcess.registerOnMessageappProcess.registerOnStateChangefeatures.isSupportedfeatures.registerOnSupportChangegetPlatformInfonotification.addToastrequestOpenExternalUrl
appProcess.registerOnMessage
API reference for the appProcess.registerOnMessage method.
Registers a callback that listens for broadcasted messages.
Usage: Listen for inter-process messages
import { appProcess } from '@canva/platform';const messageDisposer = appProcess.registerOnMessage(async (sender, message) => {const { appProcessId, surface } = sender;// Handle message from other process});// Later: cleanup the listenerawait messageDisposer();
TYPESCRIPT
Parameters
callbackOnMessageCallbackRequired
The callback that listens for broadcasted messages.
Parameters
senderobjectRequired
Information about the process that sent the message.
- sender.appProcessId - The ID of the process that sent the message.
- sender.surface - The surface of the process that sent the message.
appProcessIdAppProcessIdRequired
The unique identifier of an app process.
surfaceAppSurfaceRequired
The type of surface on which an app process can run.
The possible surfaces include:
"headless"- A surface for when there is no visible user interface."object_panel"- A surface that renders a user interface in the side panel of the Canva editor."selected_image_overlay"- A surface that can be opened on top of a selected image.
Available values:
"object_panel""selected_image_overlay""headless"
messageanyRequired
The broadcasted message.
Returns
Promise<void>
Returns
A disposer function that cleans up the registered callback.
() => Promise<void>