Sub topic 3
Working in Experience Builder
This chapter assumes you know how Experience Cloud sites are structured and that a site runs on either the Aura or the LWR runtime. You should also have a deployable Lightning web component bundle in a Salesforce DX project. Here you learn how Experience Builder is organized, how your component appears in it, and how editing, previewing, and publishing fit together.
What Experience Builder is
Experience Builder is the visual editor for an Experience Cloud site. Administrators and developers use it to arrange pages, drop components onto them, set component properties, and control the theme. A developer's custom component becomes one more item in the editor's component list, next to the standard ones.
To open it, go to Setup, search for Digital Experiences, choose All Sites, and click Builder next to your site. You can also open it from the site's workspace.
Builder edits a draft of the site. Visitors never see draft changes until someone publishes. This separation is the main idea of the chapter. Everything you do in Builder falls into one of three activities: editing, previewing, or publishing.
The main areas of the editor
The layout differs a little between Aura and LWR sites and between releases, but the pieces are consistent.
| Area | What you do there |
|---|---|
| Canvas | Shows the current page. You click a component here to select it. |
| Pages | Lists the site's pages, lets you switch between them, and opens page settings such as the URL and page properties. |
| Components | Lists standard, custom, and (where supported) managed components that you can drag onto the canvas. |
| Property editor | Appears on the right when a component is selected. It shows the properties the component exposes. |
| Theme | Holds branding settings such as colors, fonts, and the layout used by pages. |
| Settings | Holds site-level options, such as general settings, security, and languages. |
| Preview and Publish | Previews the draft at different screen sizes and pushes the draft live. |
Two areas matter most when you build custom components: the Components list, where your work appears, and the property editor, where administrators configure it.
How your component gets into the Components list
Builder does not scan your source code. It reads metadata from the org. A component shows up only when its meta file marks it as exposed and lists a site target. Chapter "Exposing a component to Experience Builder" covers those settings in detail. For now, remember that a bundle appears in Builder only when three things are true:
- The bundle is deployed to the org that owns the site.
- Its meta file sets
isExposedtotrue. - Its targets include a site target such as
lightningCommunity__Page.
The Case List example from the plan uses this meta 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>Case List</masterLabel>
<targets>
<target>lightningCommunity__Page</target>
<target>lightningCommunity__Default</target>
</targets>
<targetConfigs>
<targetConfig targets="lightningCommunity__Default">
<property name="maxRows" type="Integer" default="5" label="Maximum rows" />
</targetConfig>
</targetConfigs>
</LightningComponentBundle>The masterLabel is the name administrators see in the Components list. The label on the property is the field name they see in the property editor. Choose both for the people who edit pages, not for developers.
A first walkthrough
Follow these steps to see the cycle with your own component.
- Deploy the bundle from your DX project:
``bash sf project deploy start --source-dir force-app/main/default/lwc/caseList ``
- Open Builder for your site. If Builder was already open, reload the browser tab. Builder reads the component list when it loads, so a component deployed afterward does not appear until you reload.
- Open the Components list and find Case List. Custom components are normally grouped separately from the standard ones, and there is a search box if the list is long.
- Drag the component onto a page region in the canvas. A region is a drop area defined by the page layout.
- Select the component. The property editor shows Maximum rows with the default value 5. Change it to 10.
- Click Preview to see the page as a visitor would see it.
- When you are satisfied, click Publish.
Because maxRows is passed to the component through an @api property, changing the value in the editor changes what the component receives. The component does not need to know Builder exists.
Editing, previewing, and publishing
These three activities have different effects, and mixing them up causes most of the early surprises.
Editing
Edits save to the draft as you work. The draft is stored in the org, so other administrators who open Builder see it too. Editing does not change what visitors see.
Previewing
Preview opens the draft in a mode that looks like the live site. It has device-size controls, so you can check a desktop, tablet, or phone layout. Preview is the place to test layout and property values.
Preview runs as you, the logged-in administrator. It does not show what a guest visitor or a different external user sees. A page that works in preview can still show an empty list or an access error to a guest, because object, field, and record access differ between users. Always verify guest behavior by logging out or using a private window against the published URL. The security chapters return to this.
Publishing
Publish copies the draft to the live site. The first publish of a new site and later publishes behave a little differently, and on LWR sites a publish creates a new site version, so it can take longer than on Aura sites. Allow a few minutes, and wait for the confirmation that the publish finished before testing the live URL.
What differs between Aura and LWR in Builder
The editor feels the same at first, but it exposes different features depending on the runtime.
- Templates and themes. Aura sites use Aura-based templates and theme layout components. LWR sites use LWR templates, and their branding is set through styling properties and theme settings.
- Component availability. Some standard components exist only for one runtime. If a component is missing from the list, check that it is supported in your site's runtime before assuming a deployment error.
- Targets in custom components. Both runtimes use the
lightningCommunity__PageandlightningCommunity__Defaulttargets. Which extra features a component can use depends on the runtime. - Publish behavior. LWR publishing builds a new version of the site, which is why it takes longer.
Common problems and how to read them
- Component not in the list. Check that the bundle deployed to the right org, that
isExposedistrue, that a site target is present, and that you reloaded Builder. - Property missing in the editor. The
targetConfigmust list the target the page uses. Properties defined for one target do not show for another, and the property name must match an@apifield on the class. - Old property labels or values. Deployed metadata updates the property definition, but a component already placed on a page keeps the value saved on that page. Re-select it and check the value.
- Works in preview, fails when published. Compare the user context. Preview runs as you. The live site runs as a guest or external user with different permissions.
- Page looks right in Builder but wrong on a phone. Use the device-size controls in preview before publishing.
Working as a team
More than one person can open Builder for the same site, and they all work on the same draft. Agree who publishes, and tell others before you do. When you change page content as part of a release, treat the publish as a release step rather than a casual click. The deployment chapter covers moving site configuration between orgs.
Exercise
You deployed a new component and set isExposed to true, but it does not appear in the Components list of a Builder tab that was already open. What should you do first, and why?
Show answer
Reload Builder. Builder reads the available components when it loads, so a component deployed afterward does not appear in a tab that is already open. If it still does not appear, check that the bundle deployed to the right org and that its targets include a site target such as lightningCommunity__Page.
Exercise
A page shows 10 cases in preview, but a guest visitor sees an empty list on the published site. Preview and publish were both done correctly. What is the most likely cause?
Show answer
Preview runs as the logged-in administrator, who has broader access than the guest user. The guest user probably lacks object, field, or record access to Case, so the Apex query returns no rows. Check the guest user profile and sharing settings, then test by visiting the published site while logged out.
Exercise
You change the maxRows default in the meta file from 5 to 8 and redeploy. A page that already contains the component still shows 5. Why?
Show answer
The page stores the property value that was saved when the component was configured. The new default applies to components placed afterward. To change existing pages, select the component in Builder and set the value, then publish.