Sub topic 1
Experience Cloud Sites and Where LWC Fits
Prerequisites
This chapter assumes basic Lightning web component (LWC) structure, JavaScript classes and decorators, Salesforce data access, and Salesforce CLI project layout.
Experience Cloud and LWC
Experience Cloud sites provide branded pages for customers, partners, or other external users. An LWC is a reusable interface component that can run inside those pages. You can place standard components and custom LWCs together in Experience Builder.
A site has two important parts:
- The site runtime renders pages and components.
- Experience Builder lets an administrator arrange components and configure properties.
Aura Sites Versus LWR Sites
Aura sites use the Aura-based Experience Cloud runtime. LWR sites use the newer Lightning Web Runtime, which is optimized for faster, standards-based delivery.
| Concern | Aura site | LWR site |
|---|---|---|
| Runtime | Aura framework | Lightning Web Runtime |
| Component support | Broad legacy support | LWC-focused support |
| Design approach | Aura and LWC components | Modern LWC components |
Check the site runtime before selecting APIs or components. An LWC may need different metadata targets or supported features depending on the runtime.
Working in Experience Builder
Open the site in Experience Builder and drag an exposed component onto a page. The property panel displays the component's editable design properties. Changes made there become page configuration, not hard-coded JavaScript values.
Preview the page as different users. A guest visitor and an authenticated customer can have different permissions, data, and navigation results.
Exposing a Component to Experience Builder
The component's *-meta.xml file controls whether Experience Builder can discover it. Set isExposed to true, then add the appropriate Experience Cloud targets.
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>60.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Case List</masterLabel>
<targets>
<target>lightningCommunity__Page</target>
<target>lightningCommunity__Default</target>
</targets>
</LightningComponentBundle>lightningCommunity__Page makes the component available as a page component. lightningCommunity__Default supports placement in the site's default content areas.
Adding Configurable Properties
A target configuration declares values that an administrator can edit. The property name must match an @api property in the JavaScript class.
<targetConfigs>
<targetConfig targets="lightningCommunity__Default">
<property name="maxRows" type="Integer"
default="5" label="Maximum rows" />
</targetConfig>
</targetConfigs>The component can then receive the configured value:
import { LightningElement, api } from 'lwc';
export default class CaseList extends LightningElement {
@api maxRows = 5;
}Keep properties focused on presentation or safe behavior, such as row limits or headings. Enforce access control in Apex and Salesforce permissions, not in editable page properties.
Exercise
Why must an LWC have both isExposed set to true and an Experience Cloud target?
Show answer
isExposed permits discovery, while the target identifies where Experience Builder can place the component.