The confluence:backgroundScript
module adds an invisible container across various Confluence views. This container lets you run app functions in the background of a page, such as:
Property | Type | Required | Description |
---|---|---|---|
key |
| Yes | A key for the module, which other modules can refer to. Must be unique within the manifest.
Regex: |
resource |
| Required if using custom UI or the latest version of UI Kit. | A reference to the static resources entry that your context menu app wants to display. See resources for more details. |
render |
| Yes for UI Kit. | Indicates the module uses UI Kit. |
resolver | { function: string } or{ endpoint: string } | Set the Set the |
Property | Type | Description |
---|---|---|
type | string | The type of the module. |
You can use the events API to enable communication between a Confluence background script and homepage feed module. Either script and feed may be rendered first, you'll need to handle both independently:
Background script:
1 2import { events } from '@forge/bridge'; // Emit the data to an already rendered homepage feed events.emit('app.data-change', 'initial-data'); // Listen to data change requests from homepage feeds events.on('app.request-data', (payload) => { events.emit('app.data-change', 'initial-or-changed-data'); });
Homepage feed:
1 2import { events } from '@forge/bridge'; // Request data in case the background script is already rendered events.emit('app.request-data'); // Listen to data change events.on('app.data-change', (payload) => { console.log('The data has changed:', payload) });
Manifest:
1 2modules: confluence:backgroundScript: - key: confluence-background-script resource: main render: native confluence:homepageFeed: - key: confluence-background-script-homepage-feed title: Hello world! description: Homepage feed that talks with a background script resource: main render: native
Rate this page: