Platform Navigation Item API

lightning/platformNavigationItemApi

Work with navigation items in the menu of a Lightning console app by using the lightning/platformNavigationItemApi module. The lightning/platformNavigationItemApi module requires API version 67.0 or later.

For Use In

Lightning Experience

The lightning/platformNavigationItemApi module provides methods to control navigation items in the menu of a Lightning console app. All the methods return a promise. The setSelectedNavigationItem method requires the navigation item’s developerName to be passed as an argument. The other methods take no arguments.

To use the Navigation Item API in your component, import the functions in your component’s JavaScript file.

1import {
2  focusNavigationItem,
3  getNavigationItems,
4  getSelectedNavigationItem,
5  refreshNavigationItem,
6  setSelectedNavigationItem,
7} from "lightning/platformNavigationItemApi";

This example selects the Accounts navigation item in the Lightning console app.

1// c/myComponent.js
2import { LightningElement, wire } from "lwc";
3import {
4  IsConsoleNavigation,
5  setSelectedNavigationItem,
6} from "lightning/platformNavigationItemApi";
7
8export default class MyComponent extends LightningElement {
9  @wire(IsConsoleNavigation) isConsoleNavigation;
10
11  onSelectAccounts(event) {
12    if (!this.isConsoleNavigation) {
13      return;
14    }
15    setSelectedNavigationItem("standard-Account").then((isSelected) => {
16      console.log(
17        `Select navigation item ${isSelected ? "successfully" : "failed"}`,
18      );
19    });
20  }
21}

For this module’s documentation, see Methods for Navigation Items in Lightning Experience in the Console Developer Guide.

error fallback image
No specifications to show
No specifications are available for this component or API module. When specifications are defined, they'll appear here.