I am trying to figure out how to add a Lightning Web Component to a Lightning tab. I have it on the Home Page, but I would like it to be on its own tab. I feel like there should be an option to expose it to the Lightning tabs. When I am in the Tabs section, I don't see my LWC listed.
-
1You can if you have a Lighting Page Tab created.– Jayant DasMar 14, 2019 at 15:27
-
@JayantDas how about lightning component tab?– Pranay JaiswalMar 14, 2019 at 15:39
-
1@PranayJaiswal as long as your LWC is wrapped within an Aura component, then Yes. Because you cannot really edit a Lighting (Aura) Component tab but only associate it with an aura component.– Jayant DasMar 14, 2019 at 15:42
5 Answers
From Winter 20 release you are able to set it as Tab. All you need to do is:
- Open
-meta.xml
file from your LWC component - Change is exposed to True:
<isExposed>true</isExposed>
- Add
<target>lightning__Tab</target>
- Open Tab from setup and under Lightning Component Tabs press New and select your LWC component.
Your file at the end should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>47.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__Tab</target>
</targets>
</LightningComponentBundle>
As stated in comments, My Domain
is a prerequisite to Lightning Component Tabs
-
2
With Winter 20 release, we can create the Lightning Tab using LWC component. You will just have to add the below tag in the -meta.xml
file of LWC component.
<target>lightning__Tab</target>
-
Although this will be good IF Salesforce does release this and their safe harbour statements mean you cannot rely on this info.– TimAug 16, 2019 at 8:42
-
It's available in Summer'20 Pre-Release Org. You can cross-verify there. Aug 17, 2019 at 10:36
-
2Your answer is only partially correct. The full solution is on this link : salesforcecodecrack.com/2019/08/…– compskiOct 10, 2019 at 9:19
I was able to do this by:
- Setup
- Lightning App Builder
- List item
- Create a new App Page
- Add the LWC to the page
- Associate the page with an App
-
2
-
@compski I don't understand your comment. The solution I listed was a way to accomplish what I needed. I put the LWC on a page, added the page to an app, and then assigned the app to a tab. Oct 11, 2019 at 10:59
-
Why do you need to put LWC on a page to then assign it to a tab? Your question after all was "When I am in the Tabs section, I don't see my LWC listed." This article shows you how to have it on Tab section and have ur LWC listed salesforcecodecrack.com/2019/08/…– compskiOct 13, 2019 at 6:07
So far (Spring '19), using a Lightning web component inside a tab isn't supported, as listed here.
What you can do is wrap it inside an aura component, and create a tab for it.
I was facing the same problem, after tried various solutions, I noticed in Setup -> Tabs is a link for help: https://help.salesforce.com/articleView?id=dev_tabdef.htm&type=5, there say for see Lightning Component Tabs you need a deployed my domain:
NOTE To expose Lightning components via Lightning component tabs, you must enable and deploy My Domain.
I deployed My Domain in Setup-> My Domain and then in tabs appears the option Lightning Component Tabs