Lightning Out 2.0 is **not** a simple library upgrade. It is an entirely different embedding paradigm built on Web Components and iframes. This reference captures the essential architecture, constraints, and mental model. --- ### 1. Foundational Mental Model #### Core Principle: Dual-Context Architecture LO 2.0 creates a **two-world system** on every host page: | Context | Runs on | Contains | Controlled by | | ---------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------- | ------------------ | | **Host page context** | The external (non-Salesforce) page | LO 2.0 web components (shells), the `lightning-out-application` element, host page JS | The developer | | **Salesforce context** | Inside iframes within closed shadow DOMs | The actual LWC components, Salesforce platform services (LDS, Apex, etc.) | Salesforce runtime | **Why this matters for migration**: In Lightning Out Beta, the LWC ran directly on the host page via `$Lightning.createComponent()`. In LO 2.0, the LWC is isolated inside an iframe. This means: - Host page JavaScript **cannot** directly access DOM inside the LWC. - The LWC **cannot** directly access host page DOM. - Communication must go through the event bridge (see Section 5). - CSS from the host page does **not** cascade into the iframe (see Section 4). #### The Three Pillars of a LO 2.0 App Every LO 2.0 app on a host page consists of exactly three elements: 1. **The LO 2.0 JavaScript library** — A `