This tutorial describes how to make a Forge app that uses highlighted text from a Confluence page. You might use this technique in a dictionary app, a custom glossary, or any app that requires users to highlight text on a page.

To create the app, you'll learn how to:
This tutorial assumes you're already familiar with the basics of Forge development. If this is your first time using Forge, see Getting started first.
To complete this tutorial, you need the following:
npm install -g @forge/cli@latest
on the command line.npm install @forge/ui@latest --save on the command line.You need an Atlassian site where you can install and test your app.
You can provision a Forge demo development site from the CLI. Demo sites include realistic seeded data and enterprise editions of Jira, Confluence, Jira Service Management, and Rovo.
To provision a demo site before installing an app, run:
1 2forge site provision
Alternatively, deploy your app and run forge install --demo-site. The CLI reuses your latest
active demo site, or offers to provision one if none exists.
Demo sites are active for 90 days by default. For more information, see Provision a demo development site.
Alternatively, create a traditional Atlassian cloud developer site:
You can install your app to multiple Atlassian sites. However, app data won't be shared between separate Atlassian apps, sites, or Forge environments.
The following user limits apply to traditional cloud developer sites:
Create an app starting from the macro template.
Navigate to the directory where you want to create the app.
Create an app by running:
1 2forge create
Open the app directory to see the app files.
This app uses a confluence:contextMenu module. All apps that use this module appear in the dropdown
in the context menu.
manifest.yml file.Your manifest.yml should look like the following, with your value for the app ID:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19modules: confluence:contextMenu: - key: hello-world-context-menu resource: main render: native resolver: function: resolver title: Hello World! function: - key: resolver handler: index.handler resources: - key: main path: src/frontend/index.jsx app: runtime: name: nodejs24.x id:
See Manifest to learn more about the manifest file.
Build, deploy, and install the app to see it in your Confluence site.
Navigate to the app's top-level directory and deploy your app by running:
1 2forge deploy
Install your app using one of the following commands:
To install to your latest active Forge demo development site, or provision one if needed:
1 2forge install --demo-site
Demo sites include realistic seeded data and are active for 90 days by default.
To select an existing Atlassian site:
1 2forge install
If prompted, select your Atlassian context using the arrow keys and press the enter key.
If prompted, enter the URL for your development site. For example, example.atlassian.net. View a list of your active sites at Atlassian administration.
Once the successful installation message appears, your app is installed and ready
to use on the specified site.
You can always delete your app from the site by running the forge uninstall command.
With the app installed, you can see the new entry in the context menu.
You'll see your app appear there.
Add UI elements that render when the app is called (when the user clicks on the menu item). You'll use the useProductContext UI Kit hook to get information about the selected text.
In terminal, navigate to the app's top-level directory and start tunneling to view your local changes by running:
1 2forge tunnel
Open the src/frontend/index.jsx file.
Replace the content of the file with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21import React from 'react'; import ForgeReconciler, { Text, Strong, useProductContext } from '@forge/react'; const App = () => { const context = useProductContext(); const selectedText = context?.extension.selectedText; return ( <> <Text><Strong>Selected text</Strong></Text> <Text>{selectedText}</Text> </> ); }; ForgeReconciler.render( <React.StrictMode> <App /> </React.StrictMode> );
Open a Confluence page and select some text. When the menu appears, click the dropdown button and select your app.

In the code from this step:
App component renders app with selected text.
selectedText is retrieved from useProductContext.Text UI Kit component displays the selected text.After confirming the app works locally, deploy the app so that it continues to work when you close the tunnel.
Close your tunnel by pressing Ctrl+C.
Deploy your app by running:
1 2forge deploy
Now you know how to build a simple Forge app using the confluence:contextMenu module.
Review other documentation for more on how Forge works:
Rate this page: