The js-meta.xml file decides where a Lightning Web Component can be used and what an admin can configure when they drop it on a page. <targets> lists the places (record page, app page, Flow screen, Experience Cloud page and so on). <targetConfigs> adds settings for each of those places: design properties, the objects a record page component supports, form factors, and Flow input and output roles. If a component is missing from App Builder, or a property doesn't show up, the cause is almost always in this file.
Below: the full structure of the file, each common target, targetConfig options for record pages, Flow screens and Experience Cloud, and the errors I see most often.
The structure of a js-meta.xml file
Every component folder has one. For a component called accountSummary, the file is accountSummary.js-meta.xml.
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>62.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Account Summary</masterLabel>
<description>Shows rating, industry and open cases for an account.</description>
<targets>
<target>lightning__RecordPage</target>
<target>lightning__AppPage</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__RecordPage">
<property name="showCases" type="Boolean" default="true" label="Show open cases" />
<objects>
<object>Account</object>
</objects>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
What each tag does:
apiVersion: the API version the component compiles against. Use the latest version your org supports.isExposed:truemakes the component available to the builders (App Builder, Experience Builder, Flow Builder). Withfalse, other components can still use it as a child, but admins can't place it.masterLabel: the name admins see in the component palette. Without it, they see the folder name.description: shown in the builder as a tooltip.targets: where the component can be placed.targetConfigs: extra settings per target. Every target you name inside atargetConfigmust also be in<targets>.
One thing to keep in mind: if the component ships in a managed package, you can't set isExposed back to false after the package is released. Decide early.
The targets you'll use most
| Target | Where the component shows up |
|---|---|
lightning__RecordPage | Lightning record pages in App Builder |
lightning__AppPage | App pages in App Builder |
lightning__HomePage | Home pages in App Builder |
lightning__Tab | A custom Lightning component tab |
lightning__UtilityBar | The utility bar of a Lightning app |
lightning__RecordAction | A quick action on a record page |
lightning__FlowScreen | A screen component in Flow Builder |
lightningCommunity__Page | The Experience Builder component palette |
lightningCommunity__Default | Editable properties in Experience Builder |
lightning__Inbox | The Outlook and Gmail integration panes |
Salesforce adds new targets from release to release, so check the targets reference when you need something less common.
targetConfig for record pages: properties, objects and form factors
A record page component usually wants two things: the current record, and a few settings the admin can change.
<targets>
<target>lightning__RecordPage</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__RecordPage">
<property name="title" type="String" default="Account health" label="Card title" />
<property name="maxRows" type="Integer" default="5" min="1" max="20" label="Rows to show" />
<property name="priority" type="String" datasource="Low,Medium,High" default="Medium" label="Minimum priority" />
<objects>
<object>Account</object>
<object>Opportunity</object>
</objects>
<supportedFormFactors>
<supportedFormFactor type="Large" />
<supportedFormFactor type="Small" />
</supportedFormFactors>
</targetConfig>
</targetConfigs>
propertyshows up as a field in the App Builder panel on the right.typecan beBoolean,IntegerorStringhere. Adatasourcewith comma-separated values turns a String into a picklist.objectslimits the component to the record pages of those objects. Leave it out and the component is available on every object's record page.supportedFormFactorssays whether the component runs on desktop (Large), phone (Small) or both.
Each property needs a matching @api field in JavaScript, with exactly the same name:
import { LightningElement, api } from 'lwc';
export default class AccountHealth extends LightningElement {
@api recordId;
@api objectApiName;
@api title;
@api maxRows;
@api priority;
}
recordId and objectApiName are not design properties. You don't list them in the XML. On a record page, Salesforce fills them in for you as long as you declare them with @api.
targetConfig for Flow screens: inputs, outputs and record types
A Flow screen component has two-way traffic. The flow passes values in, and the component passes values back.
<targets>
<target>lightning__FlowScreen</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__FlowScreen">
<property name="account" type="@salesforce/schema/Account" label="Account" role="inputOnly" />
<property name="startDate" type="Date" label="Start date" role="inputOnly" />
<property name="selectedContacts" type="@salesforce/schema/Contact[]" label="Selected contacts" role="outputOnly" />
<property name="notes" type="String" label="Notes" />
</targetConfig>
</targetConfigs>
role="inputOnly": the flow can set it, but can't read it back.role="outputOnly": the flow can read it, but can't set it.- No
role: both directions. - Types: Flow supports more types than App Builder.
Boolean,Date,DateTime,IntegerandString, records with@salesforce/schema/Account, collections with[], and Apex-defined types withapex://ClassName.
To send a value back, change the property and tell the flow about it:
import { LightningElement, api } from 'lwc';
import { FlowAttributeChangeEvent } from 'lightning/flowSupport';
export default class ContactPicker extends LightningElement {
@api account;
@api startDate;
@api selectedContacts = [];
@api notes;
handleSelection(event) {
this.selectedContacts = event.detail.rows;
this.dispatchEvent(new FlowAttributeChangeEvent('selectedContacts', this.selectedContacts));
}
}
If you only change the property and skip the event, the flow often still sees the old value. That's the bug I get asked about most for Flow screen components. More on this in using an LWC in Salesforce Flows.
targetConfig for Experience Cloud: lightningCommunity__Page vs lightningCommunity__Default
This is where most people get confused, because Experience Cloud uses two targets for one job.
lightningCommunity__Pageputs the component in the Experience Builder component palette, so a site admin can drag it onto a page.lightningCommunity__Defaultlets the site admin edit the component's properties in Experience Builder. Properties go in atargetConfigfor this target.
So a configurable component needs both:
<targets>
<target>lightningCommunity__Page</target>
<target>lightningCommunity__Default</target>
</targets>
<targetConfigs>
<targetConfig targets="lightningCommunity__Default">
<property name="heading" type="String" default="Our latest products" label="Heading" />
<property name="showPrices" type="Boolean" default="true" label="Show prices" />
<property name="cardsPerRow" type="Integer" default="3" label="Cards per row" />
<property name="accentColor" type="Color" default="#0176d3" label="Accent color" />
<property name="recordId" type="String" default="{!recordId}" label="Record ID" />
</targetConfig>
</targetConfigs>
Two details that trip people up:
recordIdon Experience Cloud pages is not filled in automatically. Add it as a property withdefault="{!recordId}", as above, and the builder binds it to the record in the page URL.- Experience Builder supports a
Colortype that App Builder doesn't. Admins get a color picker.
For custom page and theme layouts there are two more targets: lightningCommunity__Page_Layout and lightningCommunity__Theme_Layout.
One component, several targets
You can list several targets and give each its own settings. A targetConfig can also cover more than one target with a comma-separated list.
<targets>
<target>lightning__RecordPage</target>
<target>lightning__AppPage</target>
<target>lightning__HomePage</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__RecordPage">
<property name="showCases" type="Boolean" default="true" />
<objects>
<object>Account</object>
</objects>
</targetConfig>
<targetConfig targets="lightning__AppPage, lightning__HomePage">
<property name="title" type="String" default="My accounts" />
</targetConfig>
</targetConfigs>
Your JavaScript then has to cope with properties that are empty on some pages. Give every @api property a sensible default in code, not just in the XML. The XML default only applies when an admin first drops the component on a page.
Errors I see most often
- The component doesn't appear in the builder.
isExposedisfalse, the page type isn't intargets, orobjectsdoesn't include the object you're editing. - The deploy fails on a
targetConfig. Thetargetsattribute names a target that isn't in<targets>. Every target in atargetConfigmust be listed in<targets>too. - A property doesn't show up. The property is in a
targetConfigfor a different target. For Experience Cloud it must be underlightningCommunity__Default, notlightningCommunity__Page. - The property name doesn't match the
@apifield. Names are case-sensitive.maxRowsin XML andmaxrowsin JS are two different things. Also, don't start a property name withon, because the framework treats those as event handlers. - A Flow output stays empty. The component never dispatched
FlowAttributeChangeEvent. - A changed default does nothing. Defaults only apply to new placements. Pages that already use the component keep the value they were saved with.
If you want the full list of where a component can live, I wrote a shorter overview in sourcing LWC in Lightning. For building these components step by step in a real org, see the Lightning Web Components course.
Learn it by building it
Every course, every code repository, the discussion group and certificates of completion โ one subscription.
Frequently asked questions
What is the difference between targets and targetConfigs in js-meta.xml?
targets decides where a component can be placed, such as a record page or a Flow screen. targetConfigs adds settings for those places: the properties an admin can fill in, the objects a record page component supports, and the form factors it runs on.
Do I need both lightningCommunity__Page and lightningCommunity__Default?
Add lightningCommunity__Page to show the component in the Experience Builder palette. Add lightningCommunity__Default, with a targetConfig, when you also want admins to edit its properties in Experience Builder. Most components need both.
Why doesn't my LWC show up in App Builder?
Check that isExposed is true, that the page type you're building is listed in targets, and that the record page's object is listed in objects if you used that tag. Then deploy again and refresh the builder.
How does a Flow screen get a value back from an LWC?
Mark the property as outputOnly (or leave role out), declare it with @api in JavaScript, and dispatch a FlowAttributeChangeEvent from lightning/flowSupport whenever the value changes.
Keep going
Blog
Sourcing LWC in Lightning
Blog
Using a Lightning Web Component in Salesforce Flows
Topic guide
Learn Lightning Web Components: Basics to Real Projects
Blog
Learn JavaScript Before LWC: The 12 Concepts That Matter
Blog
Why LWC Templates Block Expressions and How Getters Fix It
Blog
How to Crack a Salesforce Developer Interview: A 30-Day Plan