This tutorial describes how to create a Forge app with two modules, where an admin can create
news content using spaceSettings
module, and make the news content available using contentBylineItem
.
The final spaceSettings
module looks like the following:
The final contentBylineItem
module looks like the following:
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 latest version of Forge CLI. To update your CLI version, run npm install -g @forge/cli@latest
on the command line.
An Atlassian cloud developer site lets you install and test your app on Confluence and Jira products set up for you. If you don't have one yet, set it up now:
You can install your app to multiple Atlassian sites. However, app data won't be shared between separate Atlassian sites, products, or Forge environments.
The limits on the numbers of users you can create are as follows:
The Atlassian Marketplace doesn't currently support cross-product apps. If your app supports multiple products, you can publish two separate listings on the Marketplace, but your app won't be able to make API calls across different products and instances/installations.
Create an app based on the confluence-macro template.
1 2forge create
To register the functionality of your app, add confluence:spaceSettings
and function
modules to
the manifest.
The confluence:spaceSettings
module adds a tab inside the integration settings of a Confluence space.
The function
modules contains the implementation of space settings and content byline items modules.
In the app's top-level directory, open the manifest.yml
file.
Replace the macro
entry under modules
with the following confluence:spaceSettings
.
1 2confluence:spaceSettings: - key: forge-space-news resource: settings render: native title: Space news
Add permissions to the manifest.yml
file, so the app can read and write space settings.
1 2permissions: scopes: - 'read:space:confluence' - 'write:space:confluence'
Your manifest.yml
should look like the following, with your value for the app ID:
1 2modules: confluence:spaceSettings: - key: forge-space-news resource: settings render: native title: Space news permissions: scopes: - 'read:space:confluence' - 'write:space:confluence' resources: - key: settings path: src/frontend/index.jsx app: id: '<your-app-id>'
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 by running:
1 2forge install
Select your Atlassian product using the arrow keys and press the enter key.
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.
Running the forge install
command only installs your app onto the selected product.
To install onto multiple products, repeat these steps again, selecting another product each time.
Note that the Atlassian Marketplace
does not support cross-product apps yet.
You must run forge deploy
before running forge install
in any of the Forge environments.
With the app installed, it's time to see the entry in Space Settings.
You'll see the Space news tab from the app.
If you select the menu item, the default hello world content will be displayed, because you haven't implemented the app logic yet. You'll do this in the next step.
1 2forge tunnel
src/index.jsx
file.1 2import React from "react"; // Import required components from the UI kit import ForgeReconciler, { TextArea, useSpaceProperty, useForm, Form, Button, } from "@forge/react"; const App = () => { const [news, setNews] = useSpaceProperty("space-news", "No news currently."); const { register, handleSubmit } = useForm({ defaultValues: { news, }, }); const onSubmit = async ({ news }) => { await setNews(news); }; return ( <Form onSubmit={handleSubmit(onSubmit)}> <TextArea {...register("news")} /> <Button type="submit">Submit</Button> </Form> ); }; ForgeReconciler.render( <React.StrictMode> <App /> </React.StrictMode> );
In the code from this step:
TextArea
provides a text area input control. It's used to collect the news entry.Form
contains the TextArea
component. It also has onSubmit
property.
onSubmit
is called with form data when a user presses the submit button.useForm
is a hook that provides form state and methods to manage form data.ForgeReconciler.render
provides the mechanism that renders the app.To add more functionality to your app, add confluence:contentBylineItem
.
The confluence:contentBylineItem
module displays Forge apps in the content byline section
(the area under the page title) of a Confluence page.
manifest.yml
file.modules
after confluence:spaceSettings
with the following
confluence:contentBylineItem
.
1 2confluence:contentBylineItem: - key: forge-space-news-byline resource: byline render: native title: Space news tooltip: Displays recent space news
resources
.
1 2- key: byline path: src/frontend/byline.jsx
Your manifest.yml
should look like the following, with your value for the app ID:
1 2modules: confluence:spaceSettings: - key: forge-space-news resource: settings render: native title: Space news confluence:contentBylineItem: - key: forge-space-news-byline resource: byline render: native title: Space news tooltip: Displays recent space news permissions: scopes: - 'read:space:confluence' - 'write:space:confluence' resources: - key: settings path: src/frontend/index.jsx - key: byline path: src/frontend/byline.jsx app: id: '<your-app-id>'
src/frontend/byline.jsx
file.1 2// Import required components from the UI kit import React from "react"; import ForgeReconciler, { Text, useSpaceProperty } from "@forge/react"; const App = () => { const [news] = useSpaceProperty("space-news", "No news currently."); return <Text>{news}</Text>; }; ForgeReconciler.render( <React.StrictMode> <App /> </React.StrictMode> );
In the code from this step:
Text
displays the news text set by admin.ForgeReconciler.render
provides the mechanism that renders the app.Build and deploy the app to see it in your Confluence site. The app needs to be redeployed after a manifest change.
Stop tunneling by pressing:
1 2Control + C
Deploy your app by running:
1 2forge deploy
With the app deployed again, it's time to see the entry in Content Byline Item. Navigate to your Confluence Cloud site, then open a page. You'll see the Space news entry from the app.
Congratulations! You've created a forge app with two modules that:
Check out an example app, continue to one of the other tutorials, or read through the reference pages to learn more.
Rate this page: