Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
IsConsoleNavigation Context Wire Adapter for Lightning Experience
To determine if the component is within a console app, use this wire adapter. If a caller component isn’t using the wire adapter inside a tab or subtab, the enclosing utility tab ID is null.
LWC Sample Code
This component checks if it’s within a Lightning console app and returns the tab information using the IsConsoleNavigation wire adapter.
1import { LightningElement, wire } from 'lwc';
2import { IsConsoleNavigation, getFocusedTabInfo } from 'lightning/platformWorkspaceApi';
3
4export class ConsoleNavExample extends LightningElement {
5 @wire(IsConsoleNavigation) isConsoleNavigation;
6
7 async handleFocusTab() {
8 if (!this.isConsoleNavigation) {
9 return;
10 }
11
12 const { tabId } = await getFocusedTabInfo();
13 // do something with the tabId
14 });
15 }
16}For another example that uses IsConsoleNavigation, see closeTab().
To make your component available for use in a Lightning console app, specify the lightning__AppPage target in the component’s configuration file.
Response
If the current app uses console navigation, this method returns true, or false otherwise.