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.current.setOnDispose
API reference for the appProcess.current.setOnDispose method.
Registers a callback that runs when the current app process is about to close.
- Apps can't register multiple callbacks.
 - If an app attempts to register multiple callbacks, only the last callback will be registered.
 - The app process will remain open until the callback resolves or a timeout error occurs.
 - The complete execution of the callback is not guaranteed as some user actions (e.g. closing tabs) may close the process prematurely.
 
Usage: Handle process cleanup
import { appProcess } from '@canva/platform';const cleanupDisposer = appProcess.current.setOnDispose(async (params) => {if (params.reason === 'completed') {await saveChanges();}});// Later: cleanup the listenerawait cleanupDisposer();
TYPESCRIPT
Parameters
callbackOnDisposeCallback<T>Required
The callback to run when the current app process is about to close.
Parameters
optsTRequired
Parameters passed to the setOnDispose callback when a process is about to close.
reasonCloseReasonRequired
The reason the app process is closing.
Available values:
"completed""aborted"
Returns
Promise<void>
Returns
A disposer function that cleans up the registered callback.
() => Promise<void>