Add Lifecycle Hooks
Learn how to respond to plugin and panel events
Overview
As we have seen in the Entrypoints concept guide, lifecycle hooks are callback functions that are automatically invoked when specific events occur during the lifecycle of a Plugin or a Panel. They are optional and can be used to perform, for example, any setup or teardown logic.
This guide is only applicable to Plugins with at least one Panel; there are no hooks related to Commands. Read here if you need a refresher on the difference between a Command and a Panel.
Hook Types
UXP provides two kinds of lifecycle hooks:
- At a Plugin level, respectively invoked when the plugin container itself is created and destroyed:
create()anddestroy(). - At a Panel level, respectively invoked when the panel is created, shown, hidden, and destroyed:
create(),show(),hide(), anddestroy().
More details on the types of hooks can be found in the Entrypoints concept guide.
Current limitations
The hide() and destroy() hooks are not working as expected yet in Premiere; this will be fixed in a future update.
For plugins with multiple panels, lifecycle hooks currently fire for all panels without distinguishing between them
Implementation
Hooks are implemented in the entrypoints.setup() method, which accepts an object with the following properties:
plugin: An object with the plugin lifecycle hooks.panels: An object with one property for each"panel"entrypoint declared in themanifest.json—using the panel IDs as property names, and objects with the panel lifecycle hooks as values.
Promises are allowed for most callbacks, as demonstrated in the following example. Panel hooks receive a rootNode parameter; it's the HTML document root node, which can be used to programmatically append or remove an appropriate container element in a multiple panels scenario.
Example
Copied to your clipboardconst { entrypoints } = require("uxp");entrypoints.setup({plugin: {create() {console.log("Plugin create hook");},destroy() {return new Promise(function (resolve, reject) {console.log("Plugin destroy hook");resolve();});},},panels: {firstPanel: { // 👈 matches the panel ID from manifest.jsoncreate(rootNode) {return new Promise(function (resolve, reject) {console.log("Panel create hook", rootNode);resolve();});},show(rootNode, data) {return new Promise(function (resolve, reject) {console.log("Panel show hook", data);resolve();});},hide(rootNode, data) {return new Promise(function (resolve, reject) {console.log("Panel hide hook", data);resolve();});},destroy(rootNode) {return new Promise(function (resolve, reject) {console.log("Panel destroy hook", rootNode);resolve();});},},},});
Copied to your clipboard{// ..."entrypoints": [{"type": "panel","id": "firstPanel","label": "My plugin","minimumSize": { "width": 400, "height": 400 },"maximumSize": { "width": 800, "height": 800 },"preferredDockedSize": { "width": 400, "height": 400 },"preferredFloatingSize": { "width": 600, "height": 600 }}],// ...}
Summary
Lifecycle hooks are callback functions that automatically execute during specific plugin and panel events, enabling setup and teardown logic for UXP plugins in Adobe Premiere.
Key Concepts:
- Plugin-level hooks:
create()anddestroy()are triggered when the plugin container is created/destroyed. - Panel-level hooks:
create(),show(),hide(), anddestroy()are triggered during panel lifecycle events. - Implementation: Use
entrypoints.setup()withpluginandpanelsobjects to define hooks. Promises are allowed for most callbacks. - Known limitations:
hide()anddestroy()hooks are not working as expected in Premiere (will be fixed in future updates). For multi-panel plugins, lifecycle hooks currently fire for all panels without distinction.

