+ Start a Discussion
AnupamAnupam 

Lightning web component not showing in lighting home or app page

Hi 

I am following the lighting web component trailhead (https://trailhead.salesforce.com/content/learn/projects/quick-start-lightning-web-components/create-a-hello-world-lightning-web-component ).
I created the web component, but when i try to add it to the home component, the custom web component is not showing and cannot add it to the home page. The helloworld.js-meta.xml file is same as what metioned in the trailhead account.
I am doing this in my trailhead playground. Any help on this will be highly appreciated
Best Answer chosen by Anupam
Khan AnasKhan Anas (Salesforce Developers) 
Hi Anupam,

Greetings to you!

+1 @Raj

Please make sure you are using the latest version of salesforcedx. To work with Lightning web components, you need version 45 or greater of the Salesforce CLI. Check the installed version.

sfdx plugins --core

NOTE: If you had a prerelease version of the CLI installed, run this command to update it.
sfdx plugins:install salesforcedx@latest

You can see these components in your org using the tooling API query from the dev console. Check the tooling checkbox in the dev console.
The below query should show you if your org has these components:
Select Id from LightningComponentBundle
Select Id from LightningComponentResource

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas 

All Answers

AnupamAnupam
This is the lighting page screenshot
Raj VakatiRaj Vakati
You need to use the  js-meta.xml file as show below and push the changes 

Refer this links 

https://rajvakati.com/2018/12/22/lightning-web-components/ 


 
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="helloWorld">
  <apiVersion>45.0</apiVersion>
  <isExposed>true</isExposed>
  <targets>
    <target>lightning__AppPage</target>
    <target>lightning__RecordPage</target>
    <target>lightning__HomePage</target>
  </targets>
</LightningComponentBundle>

 
Raj VakatiRaj Vakati
Set isExposed --> True 
Target --> lightning__HomePage
 
Khan AnasKhan Anas (Salesforce Developers) 
Hi Anupam,

Greetings to you!

+1 @Raj

Please make sure you are using the latest version of salesforcedx. To work with Lightning web components, you need version 45 or greater of the Salesforce CLI. Check the installed version.

sfdx plugins --core

NOTE: If you had a prerelease version of the CLI installed, run this command to update it.
sfdx plugins:install salesforcedx@latest

You can see these components in your org using the tooling API query from the dev console. Check the tooling checkbox in the dev console.
The below query should show you if your org has these components:
Select Id from LightningComponentBundle
Select Id from LightningComponentResource

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas 
This was selected as the best answer
AnupamAnupam
Thank you all !!

Queried the lightning resource and found that there was issue in the meta xml file which was not stored correctly. Corrected the file and now it showing under home page component.

Now i have added the component to the home page but while validating the challenge i am getting below error :
Step not yet complete in My Trailhead Playground 2
Make sure you add the 'helloWorld' Lightning web component to the default Home page.
AnupamAnupam
I resolved this by doing on the system default home page. Earlier i was doing it by creating the custom home component.
Phoenix SPhoenix S
**Update 12/2019**

In case someone is just getting to this thread like I am here's what I had to do to get the LWC to show up on my app & pass the challenge:

1. Copy the code as listed
2. When you get to the part where you're ready to add the component to the page click the option to "Delopy to my Domain" (this may not be the exact verbiage)
3. Set your domain name. *NOTE: Choose wisely because domain names cannot be changed except through Salesforce Support*
4. Once your domain is active click "Login" to test out the domain
5. Deploy the domain to your users
6. Go back to the "Sales" app and edit the page adding your lightning web component as instructed
7. Verify the challenge and get the points and badge :)

I hope this helps! 
Efren Maldonado 13Efren Maldonado 13
Lightning Componets, Aura or LWC, require My Domain activated: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/intro_reqs_my_domain.htm