Add LWC Component as a Custom Tab

Winter 20 release, we can create the Lightning Tab using Lightning Web Component. You will just have to add the <target>lightning__Tab</target> tag in the -meta.xml file of the LWC component.

Add Lightning Components as Custom Tabs

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="HelloWorld">
    <apiVersion>46.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
         <target>lightning__Tab</target>
    </targets>
</LightningComponentBundle>
After adding this deploy the component to org. then navigate to the tab page to create a custom tab.

Step:1
Setup --> Tab --> Lightning component tab--> New.
lightning-component-tab

Step:2
Select the lightning web component and follow steps.
new-LWC-tab

That's it. Now it will be available in the tabs section.
Labels:
LWC
Join the conversation