Automation modules
Bitbucket modules
Common modules
Compass modules
Confluence modules
Jira modules
Jira Service Management modules
Rovo modules

Confluence background script

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:

  • distributing shared data
  • making heavy calculations
  • running code without UI elements

Properties

PropertyTypeRequiredDescription
key

string

YesA key for the module, which other modules can refer to. Must be unique within the manifest.

Regex: ^[a-zA-Z0-9_-]+$

resource

string

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

'native'

Yes for UI Kit.Indicates the module uses UI Kit.
resolver{ function: string } or
{ endpoint: string }

Set the function property if you are using a hosted function module for your resolver.

Set the endpoint property if you are using Forge remote to integrate with a remote back end.

Extension context

PropertyTypeDescription
typestringThe type of the module.

Example

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
2
import { 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
2
import { 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
2
modules:
  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:

OSZAR »