---
title: "Control tabs with WorkspaceAPI"
url: "https://blog.beyondthecloud.dev/tips/control-tabs-with-workspaceapi"
category: "LWC"
published: "2024-04-02"
---

# Control tabs with WorkspaceAPI

With the Spring ‘24 release, Salesforce enabled the Workspace API in Lightning Web Components!

### Did you know you can use Workspace API in LWC?

With the Spring ‘24 release, Salesforce enabled the Workspace API in Lightning Web Components!

What does it mean?

![Control tabs with WorkspaceAPI — screenshot 1](https://blog.beyondthecloud.dev/tips/control-tabs-with-workspaceapi/fig-1.webp)

Now you can control your application tabs - such as Home, shown above - within your LWC code. Learn more on the next page!

By using the Workspace API, you can, for example, close one of the tabs.

```javascript
import { LightningElement, wire } from 'lwc';
import {
    IsConsoleNavigation,
    getFocusedTabInfo,
    closeTab
} from 'lightning/platformWorkspaceApi';

export default class TabController extends LightningElement {
    @wire(IsConsoleNavigation) isConsoleNavigation;

    closeHome() {
        if (this.isConsoleNavigation) {
            getFocusedTabInfo().then((tabInfo) => {
                closeTab(tabInfo.tabId);
            });
        }
    }
}
```

You can also focus, open new tab or refresh tab. Check link in post to learn more!
