Sub topic 1
The metadata file that controls App Builder access
Prerequisites
This chapter assumes you know the basic files in a Lightning web component, XML syntax, and how to use Salesforce Setup and Salesforce CLI.
A Lightning web component becomes available in Lightning App Builder through its metadata file. The file is named after the component and ends in .js-meta.xml. For a component named accountSummaryCard, the file is accountSummaryCard.js-meta.xml.
The metadata file describes where Salesforce can place the component and how administrators see it. The JavaScript class provides behavior, while the metadata file provides deployment and placement information.
Making the component available with `isExposed`
Set <isExposed>true</isExposed> to make the component available for placement. If the value is false, or the element is missing, administrators cannot select the component in App Builder.
Naming the component for admins: `masterLabel` and `description`
masterLabel is the component name displayed in App Builder. Use a clear, human-friendly name rather than the developer name. The optional description helps an administrator understand the component's purpose.
Choosing targets: app, home, and record pages
A target identifies a type of Lightning page where the component can be placed:
lightning__AppPageallows placement on an app page.lightning__HomePageallows placement on a home page.lightning__RecordPageallows placement on a record page.
The following file exposes the component on all three page types:
<?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 summary information for the current context.</description>
<targets>
<target>lightning__AppPage</target>
<target>lightning__HomePage</target>
<target>lightning__RecordPage</target>
</targets>
</LightningComponentBundle>The apiVersion specifies the Salesforce platform version used by the component metadata. The targets list does not grant access to data. It only controls the page types that accept the component.
Exercise
Which metadata setting makes a Lightning web component selectable in App Builder?
Show answer
Set isExposed to true in the component's js-meta.xml file.