Get Current App Connection Element

webflow.getCurrentAppConnectionResource()

Get the element that triggered the App Connection.

Use the webflow.getCurrentAppConnection() method to verify the App Launch location. If the App was launched from the Elemen Settings panel, you can use this method to get information on the resource this App was initiated by.

Syntax

1getCurrentAppConnectionResource(): Promise<null | AppConnectionResource>

Returns

Promise<AppConnectionResource | null>

A Promise that resolves to the AppConnectionResource of for the App. If there is not a resource associated with the App, then the Promise resolves to `null1.

Example

This example is for an App written in React. This code would be placed on the editForms page of the App

1React.useEffect(() => {
2 async function onLoad() {
3 // Await the App Connection to determine where the App was launched from.
4 // If the App was launched from an Element with the App Connection 'myAwesomeAppManageFormElement', proceed with additional actions.
5 const appConnection = await webflow.getCurrentAppConnection();
6
7 if (appConnection === "myAwesomeAppManageFormElement") {
8 // Retrieve resource details about the element associated with this App Connection.
9 // The resource provides information on the specific element initiating the App launch.
10 const resource = await webflow.getCurrentAppConnectionResource();
11
12 // Check if the resource exists and is of type 'Element'.
13 // This ensures that the App can act specifically on an element within the Designer.
14 if (resource && resource.type === "Element") {
15 const element = resource.value;
16
17 // As an example, set a custom attribute on the element.
18 // Here, you can call any appropriate API method to interact with the element, depending on your App's functionality.
19 await element.setCustomAttribute("foo", "bar");
20 }
21 }
22 }
23
24 // Execute the onLoad function upon component mount to check the App launch location and take action accordingly.
25 onLoad();
26}, []);

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny