The view object refers to the context in which a resource is loaded. For example, a modal.
The close method enables you to request the closure of the current view. For example, close a modal.
1 2function close(): Promise<void>;
1 2import { view } from "@forge/bridge"; view.close();
view.onClose is now available in Confluence and Jira as part of our Early Access Program (EAP). This bridge method is to be used with the macro custom config extension point modal. To start testing, sign up here.
By signing up for this Early Access Program (“EAP”), you acknowledge that use of the view.onClose is governed by the Atlassian Developer Terms. The view.onClose bridge method is considered “Early Access Materials”, as set forth in Section 10 of the Atlassian Developer Terms and is subject to applicable terms, conditions, and disclaimers.
For more details, see Forge EAP, Preview, and GA.
The onClose method enables you to register a callback that runs when a module-level modal is closed, such as the macro custom config modal.
For @forge/bridge modal and the UI Kit Modal component, we recommend using the inbuilt onClose prop instead.
1 2function onClose(payload: () => Promise<void>): Promise<void>;
1 2import { view } from "@forge/bridge"; view.onClose(async () => save());
The submit method enables you to request form submission on the
Jira custom field edit,
Jira custom field type edit, and
Jira context configuration views.
The submit method throws an error if the submission fails.
1 2function submit(payload: mixed): Promise<void>;
Where the payload shape is defined by the requirements of the views.
This example shows how to request form submission on a Jira custom field edit.
1 2import { view } from "@forge/bridge"; const onSubmit = async () => { const fieldValue = "new-value"; try { return await view.submit(fieldValue); } catch (e) { // Handle the error } };
The getContext method enables you to retrieve contextual information for your Custom UI app.
Before upgrading to @forge/react version 11.0.0, Confluence macro config apps relying on the useProductContext
hook or view.getContext() need to
transition to the useConfig hook in order to
properly access the latest values after the configuration updates.
1 2function getContext(): Promise<Context>; interface Context { accountId?: string; cloudId?: string; extension: ExtensionData; license?: LicenseDetails; localId: string; locale: string; moduleKey: string; siteUrl: string; timezone: string; } interface ExtensionData { [k: string]: any; } interface LicenseDetails { active: boolean; billingPeriod: string; ccpEntitlementId: string; ccpEntitlementSlug: string; isEvaluation: boolean; subscriptionEndDate: string | null; supportEntitlementNumber: string | null; trialEndDate: string | null; type: string; }
Context: An object containing contextual information about the current environment in which the app is running. The data available depends on the module in which your app is used.
license is undefined for free apps, apps not listed on the Atlassian Marketplace, and apps in development and staging environments.
See the LicenseDetails type for what information is available.manifest.yml file.1 2import { view } from "@forge/bridge"; const context = await view.getContext();
Not all of the values in the context data are guaranteed to be secure, unalterable, and valid to be used for authorization. See
App context security for more information.
The createHistory method enables your UI Kit and Custom UI app to manipulate the current page URL for routing
within full page apps.
When using this API, the path and location properties are always relative to your app's URL.
The createHistory method is only available in the following modules:
Learn how to add routing to a full page app with React Router.
1 2type LocationDescriptor = { pathname: string; search?: string; hash?: string; state?: any; }; type UnlistenCallback = () => void; type Action = "POP" | "PUSH" | "REPLACE"; function createHistory(): Promise<{ action: Action; location: LocationDescriptor; push(path: string, state?: any): void; push(location: LocationDescriptor): void; replace(path: string, state?: any): void; replace(location: LocationDescriptor): void; go(n: number): void; goBack(): void; goForward(): void; listen( listener: (location: LocationDescriptor, action: Action) => void ): UnlistenCallback; }>;
1 2import { view } from "@forge/bridge"; const history = await view.createHistory(); // e.g. URL begins as http://example.atlassian.net/example/apps/abc/123 history.push("/page-1"); // this updates the URL to http://example.atlassian.net/example/apps/abc/123/page-1 history.push("/page-2"); // this updates the URL to http://example.atlassian.net/example/apps/abc/123/page-2 history.go(-2); // this updates the URL to http://example.atlassian.net/example/apps/abc/123
The refresh method enables you to fetch the data for the parent page again,
without performing a full-page reload.
The refresh method is only available for certain Atlassian apps. You will see the error
this resource's view is not refreshable if the refresh method is not available.
At the moment, it can be used by the following modules:
1 2function refresh(): Promise<void>;
1 2import { view } from "@forge/bridge"; view.refresh();
The theme object includes the method to enable theming. View the Design Tokens and Theming page for more details.
The theme.enable method enables theming in the Forge app. This will fetch the current active theme from the host environment (e.g. Jira) and apply it in your app. It will also reactively apply theme changes that occur in the host environment so that your app and the host are always in sync.
1 2function enable(): Promise<void>;
1 2import { view } from "@forge/bridge"; await view.theme.enable();
1 2// Example usage in a React app // Make sure to call enable() before the app is mounted for tokens to be available before the first render view.theme.enable().then(() => { ReactDOM.render( <React.StrictMode> <App /> </React.StrictMode>, document.getElementById("root") ); });
The changeWindowTitle method enables you to change the title of the current document in the following Jira modules: global page, admin page, project settings page, and project page.
1 2function changeWindowTitle(newTitle: string): Promise<void>;
1 2import { view } from "@forge/bridge"; await view.changeWindowTitle("New title");
The emitReadyEvent function notifies Confluence that a Forge macro has completed loading and is ready for export or further processing. This enables Confluence or other consumers, such as our PDF export service, to reliably detect when macros are fully loaded, rather than relying on DOM scanning or timing heuristics.
This function is part of the @forge/bridge library and leverages the Forge Events API to emit an EXTENSION_READY event, including contextual information about the macro or extension that triggered it.
1 2function emitReadyEvent(): Promise<void>;
1 2import { view } from "@forge/bridge"; import { useEffect, useState } from "react"; const MyMacro = () => { const [data, setData] = useState(); useEffect(() => { const loadData = async () => { const result = await fetchData(); setData(result); // Perform any other operations your macro requires await view.emitReadyEvent(); // Notify that the macro is ready }; loadData(); }, []); return <div>{data ? "Macro content loaded" : "Loading..."}</div>; }; export default MyMacro;
The createAdfRendererIframeProps method is now available as an Early Access Program (EAP). To start testing this feature, sign up using this form.
By signing up for this Early Access Program (“EAP”), you acknowledge that use of the Forge embedded macros is governed by the Atlassian Developer Terms. Forge embedded macros are considered “Early Access Materials”, as set forth in Section 12 of the Atlassian Developer Terms and is subject to applicable terms, conditions, and disclaimers.
APIs and features under EAP are unsupported and subject to change without notice. APIs and features under EAP are not recommended for use in production environments.
For more details, see Forge EAP, Preview, and GA.
Use createAdfRendererIframeProps when building a Custom UI bodied macro that needs to display its rich-text body content, including embedded Forge apps. This function generates the properties needed for an iframe element to render the ADF document type content of a Custom UI bodied macro.
This method is for Custom UI apps only. For UI Kit, use the AdfRenderer component instead.
Your app must be a Confluence bodied macro with layout:bodied enabled in the macro module properties of the manifest file.
1 2interface FullContext { accountId?: string; cloudId?: string; workspaceId?: string; extension: ExtensionData; environmentId: string; environmentType: EnvironmentType; license?: LicenseDetails; localId: string; } function createAdfRendererIframeProps( context: FullContext, iframeId?: string ): Promise<{ id: string; src: string; onLoad: () => void; }>;
context.extension.macro.body.Returns an object with the following properties:
id will be the same as iframeId if iframeId was provided as an argument.1 2import { view } from "@forge/bridge"; function App() { // Get the contents of the bodied macro const [context, setContext] = useState(null); const [iframe, setIframe] = useState(null); useEffect(() => { view.getContext().then(setContext); }, []); useEffect(() => { if (!context) return; // Generate properties for embedded content wrapper // Pass in the embedded contents to the function // macroBody - any Valid ADF document can be passed in. view.createAdfRendererIframeProps(context).then(({ id, src, onLoad }) => // Required iframe props // id - id of the iframe so the wrapper knows where to send the embedded macro contents // src - src of the embedded content renderer // onLoad - sends embedded macro contents once iframe has initialised // You can apply any styling you like to the iframe setIframe(<iframe id={id} src={src} onLoad={onLoad} />) ); }, [context]); return ( <div> <h1>Embedded content</h1> {/* Render the embedded content where you want in your app */} {iframe || "Loading embedded content..."} </div> ); } export default App;
You can split up the ADF document object inside context.extension.macro.body and use view.createAdfRendererIframeProps more than once in your Custom UI bodied macro app. However this will affect performance as an additional iframe will be created.
Confluence live pages: This method is not supported in Confluence live pages (also known as whiteboards or live docs).
Connect macros: Macros built with Atlassian Connect cannot be embedded.
Modals: Modals in Custom UI embedded macros are not supported.
| Bridge methods | Supported in Forge embedded macros |
|---|---|
| events |
|
| i18n |
|
| invoke |
|
| invokeRemote |
|
| modal |
|
| objectStore (EAP) |
|
| realtime (Preview) |
|
| requestBitbucket | N/A |
| requestConfluence |
|
| requestJira |
|
| requestRemote |
|
| router |
|
| rovo (Preview) |
|
| showFlag |
|
| view |
|
| getEditorContent |
|
| getMacroContent |
|
| updateMacroContent |
|
| updateBylineProperties |
|
| Jira bridge APIs | N/A |
| Dashboard bridge APIs | N/A |
Rate this page: