Newer Version Available

This content describes an older version of this product. View Latest

isConsoleNavigation() for Lightning Experience

Determines whether the app it’s used within uses console navigation.

Arguments

None.

LWC Sample Code

This component checks if it’s within a Lightning console app and returns the tab information.

1import { LightningElement, wire } from 'lwc';
2import { IsConsoleNavigation, getFocusedTabInfo } from 'lightning/platformWorkspaceApi';
3export class ConsoleNavExample extends LightningElement {
4    @wire(IsConsoleNavigation) isConsoleNavigation;
5    handleClick() {
6        if (this.isConsoleNavigation) {
7            getFocusedTabInfo().then((tabInfo) => {
8                // do something with it      
9            });
10       }
11    }
12}

To use LWC Workspace API (Beta), Lightning Web Security must be enabled in the Salesforce org. LWC Workspace API is a Beta Service. Customer may opt to try such Beta Service in its sole discretion. Any use of the Beta Service is subject to the applicable Beta Services Terms provided at Agreements and Terms.

Note

Aura Components Sample Code

This component has a button that, when pressed, prints whether the current app is using console navigation.

Component code:

1<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
2    <lightning:workspaceAPI aura:id="workspace" />
3    <lightning:button label="Is Console Navigation?" onclick="{! c.isConsoleNavigation }" />
4</aura:component>

Controller code:

1({
2    isConsoleNavigation : function(component, event, helper) {
3        var workspaceAPI = component.find("workspace");
4        workspaceAPI.isConsoleNavigation().then(function(response) {
5            console.log(response);
6        })
7        .catch(function(error) {
8            console.log(error);
9        });
10    }
11})

Response

This method returns a promise that, upon success, resolves to true if the current app uses console navigation, and false otherwise.