On September 25th, 2024, we released v2 of the Apps SDK. To learn what’s new and how to upgrade, see Migration FAQ and Migration guide.

appProcess.broadcastMessage

API reference for the appProcess.broadcastMessage method.
This version of the API is a preview. Preview APIs are unstable and may change without warning. You can't release public apps using this API until it's stable.

Broadcasts a message to all of the app's active processes, not including the current process.

Usage

Broadcast primitive values

import { appProcess } from '@canva/platform';
// Broadcasting a string
appProcess.broadcastMessage('REFRESH_REQUESTED');
// Broadcasting a number
appProcess.broadcastMessage(42);
// Broadcasting a boolean
appProcess.broadcastMessage(true);
TYPESCRIPT

Broadcast simple objects

import { appProcess } from '@canva/platform';
appProcess.broadcastMessage({
id: 'user-123',
name: 'John Doe',
active: true
});
TYPESCRIPT

Broadcast complex objects

import { appProcess } from '@canva/platform';
appProcess.broadcastMessage({
type: 'DOCUMENT_UPDATE',
timestamp: Date.now(),
payload: {
documentId: 'doc-123',
version: 2,
metadata: {
title: 'Project Alpha',
tags: ['draft', 'review-needed'],
collaborators: [
{ id: 'user-1', role: 'editor' },
{ id: 'user-2', role: 'viewer' }
]
}
}
});
TYPESCRIPT

Parameters

messageanyRequired

The message to be broadcasted. This can be any kind of structured data.

Returns

void