Sub topic 1
The metadata file that controls App Builder access
A Lightning web component (LWC) is invisible to Lightning App Builder until its metadata file says otherwise. This chapter explains what that file is, what its core elements do, and how to write a minimal working version.
Prerequisites
This chapter assumes you already have the following:
- Basic LWC structure: an HTML template, a JavaScript class, and a metadata file.
- Familiarity with the Salesforce Setup UI and Lightning pages.
- A Salesforce org or sandbox where you can deploy code, with Salesforce CLI and VS Code set up.
- Basic XML syntax: elements, attributes, and nesting.
What the metadata file does
Every LWC bundle contains a file named <componentName>.js-meta.xml. For a component called accountSummaryCard, the file is accountSummaryCard.js-meta.xml. Salesforce reads it at deploy time. It does not affect how the component renders. It controls where the component can be used and how it is presented to admins.
The file answers four questions:
- Which API version does the component use?
- Is the component available to tools such as App Builder?
- What is it called in those tools?
- On which kinds of pages can it be placed?
The next chapters cover targets and properties in detail. Here we focus on the file's structure and the elements that decide visibility.
A minimal file
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>60.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Account Summary Card</masterLabel>
<description>Shows a titled card with the current record context.</description>
<targets>
<target>lightning__AppPage</target>
<target>lightning__HomePage</target>
<target>lightning__RecordPage</target>
</targets>
</LightningComponentBundle>The root element is LightningComponentBundle. Its xmlns attribute declares the Salesforce metadata namespace, and deployment fails if you omit it. Everything else sits inside it.
Making the component available with isExposed
isExposed is a boolean. When it is true, the component can be used outside its own bundle, including in App Builder. When it is false or missing, the component still deploys and can be used inside other components, but App Builder does not list it.
<isExposed>true</isExposed>This is the most common reason a deployed component is "missing" from App Builder. The flag alone is not enough, though. A component needs at least one target as well, which the next section introduces.
Naming the component for admins
Two optional elements shape how admins see the component:
| Element | Purpose | Example |
|---|---|---|
| `masterLabel` | The name shown in the App Builder component list | Account Summary Card |
| `description` | Help text that explains what the component does | Shows a titled card with the current record context. |
Without masterLabel, App Builder shows the folder name in camelCase, such as accountSummaryCard. A readable label makes the component easier to find. Keep it short, because it appears in a narrow side panel.
Targets: where the component can go
The targets element lists the page types where the component can be placed. Each target is a fixed identifier:
| Target | Page type |
|---|---|
| `lightning__AppPage` | App pages |
| `lightning__HomePage` | Home pages |
| `lightning__RecordPage` | Record pages |
A component appears only on page types you list. If you expose it with only lightning__HomePage, an admin editing a record page will not see it.
Common mistakes
- Setting
isExposedtotruebut listing notargets. The component deploys but is not offered on any page. - Forgetting to redeploy after editing the file. App Builder reflects only what is in the org.
- Using a wrong target name, such as
lightning__Record. The deployment fails with a validation error. - Placing elements in the wrong order. Salesforce is tolerant here, but follow the order shown above for consistency.
Exercise
Exercise
A teammate deployed a component and says it is missing from the App Builder component list when they edit a Home page. The metadata file has <isExposed>true</isExposed> and targets listing only lightning__RecordPage. What is wrong, and how do you fix it?
Show answer
The component does not list lightning__HomePage as a target, so App Builder does not offer it on Home pages. Add <target>lightning__HomePage</target> inside <targets>, then redeploy the bundle.
Exercise
What happens to a component that has isExposed set to false and valid targets?
Show answer
It deploys successfully and can still be used inside other components, but App Builder does not list it, because isExposed must be true for it to be available there.