Sub topic 2
Aura sites versus LWR sites
This chapter assumes you can build a basic Lightning web component and read a meta file. It also assumes you know what Experience Cloud sites are. Here you learn how the two site runtimes differ and how that affects the components you write.
Two runtimes, one component model
An Experience Cloud site runs on one of two runtimes.
- Aura sites run on the Aura framework. Aura is the older Salesforce UI framework, and Lightning web components run inside it.
- LWR sites run on Lightning Web Runtime. It is built for Lightning web components only, with no Aura layer.
You pick the runtime when you create the site, by choosing a template. Treat the choice as fixed. Moving an existing site from one runtime to the other means rebuilding it.
What changes for your components
Most of your component code works in both runtimes. The meta file targets lightningCommunity__Page and lightningCommunity__Default work in both. @api properties, @wire, Apex calls, and NavigationMixin also work in both. The differences are in what surrounds the component.
| Area | Aura site | LWR site |
|---|---|---|
| Component types | Lightning web components and Aura components | Lightning web components only |
| Security model | Lightning Locker or Lightning Web Security | Lightning Web Security only |
| Page delivery | Rendered through the Aura framework | Served as a lighter page bundle that can be cached |
| Template and feature set | Broader, with more standard components | Smaller, with some standard components missing |
| Publishing | Publish applies changes to the live site | Publish creates a new site version |
The smaller feature set matters most in practice. Some standard Aura-based components, and some features that depend on them, have no LWR equivalent. Before you commit to LWR, list the standard components and features your site needs. Then check each one against the current documentation for LWR sites.
How the runtime affects your design
Two consequences follow from the table.
First, an LWR site cannot host Aura components. If you reuse a legacy Aura component, you must rewrite it as a Lightning web component first.
Second, LWR runs components under Lightning Web Security (LWS). LWS isolates each namespace's code in its own JavaScript sandbox and restricts access to some browser APIs. A component that works in an Aura site under Locker, or with no restrictions, can fail under LWS. Test in the runtime you will ship.
Common mistakes
- Choosing LWR for speed, then finding that a required standard component is unavailable.
- Assuming Aura components can be dropped into an LWR page.
- Testing only in an Aura site and shipping to LWR. Differences in LWS restrictions and available features show up late.
- Writing runtime-specific code in one shared component. Keep the component generic, and put runtime differences in the page layout and site configuration.
Exercise
A team has a site that uses one custom Aura component and several Lightning web components. They want to move to an LWR site. What must they do with the Aura component, and why?
Show answer
They must rewrite it as a Lightning web component. LWR sites support only Lightning web components, so an Aura component cannot be placed on an LWR page.