The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Five ways Lightning Web Components can share data between components (opens in a new tab)

You will see how a parent passes data to a child, how a child reports back, and when to use Lightning Message Service or Lightning Data Service instead.

Why read this

The piece also lists common mistakes to avoid.

Parent to child

  • @api public property
  • Parent sets HTML attribute
  • Child reads the value

Child to parent

  • Child dispatches CustomEvent
  • Detail carries the payload
  • Parent handles the event
Parent-to-child uses public properties; child-to-parent uses custom events

The article surveys five ways Lightning Web Components can communicate. The simplest is parent-to-child communication through a public property marked with the @api decorator, where the parent sets an HTML attribute and the child receives it. Code examples show a child component declaring a message property and a parent passing a welcome string into it.

When a child needs to notify its parent, it dispatches a custom event carrying a detail payload. The example has a child button fire a valuechange event, and the parent handles it and stores the selected value. The author notes that this lets the child report upward without reaching into the parent’s internal properties.

For components with no parent-child relationship, such as a customer information panel and a related sales panel, the article describes Lightning Message Service. The steps are to create a message channel, import it into a publisher, publish a message, subscribe in the receiving component and process the payload. Lightning Data Service is presented for cases where the data is a Salesforce record, using getRecord through a wire adapter, with the benefit of caching and record sharing across components. Shared JavaScript modules are mentioned for reusable logic.

The article closes with a table matching each method to its best use and a list of mistakes to avoid, such as using custom events where a public property is enough, creating unnecessary message channels, and calling Apex when Lightning Data Service already covers the need.

Read the original at dev.to (opens in a new tab)

Worth reading?

How LWR differs from Aura for Experience Cloud sites and what migration involves (opens in a new tab)

You will learn how Lightning Web Runtime delivers pages differently from Aura, where the performance gains come from and where they do not, and what an Aura-to-LWR migration usually involves.

Why read this

The piece helps you decide whether a new or existing site should move to LWR.

Aura

  • Components delivered dynamically
  • No republish for component changes
  • Broader existing template set

LWR

  • Static, cacheable resources
  • CDN can serve eligible files
  • Republish to expose component changes
LWR publishes cacheable resources, while Aura delivers components dynamically

Lightning Web Runtime (LWR) is the newer runtime behind Experience Cloud templates such as Build Your Own (LWR) and Microsite (LWR). Components are built with Lightning Web Components, and the site publishes prepared, cacheable resources that can be served through a content delivery network. Aura delivers components dynamically, so LWR can load faster, but the article stresses that speed is not guaranteed. Large images, unnecessary API calls and poorly designed custom components still slow pages, and integration changes may matter more than the storefront technology.

The main practical differences are in publishing and component support. Aura sites can pick up component code changes without republishing, while LWR sites must be republished for updated components to reach visitors. Standard LWR templates use LWC only, and LWR offers fewer templates and components than Aura, so some Aura features have no direct equivalent. Salesforce recommends LWR for new B2B Commerce storefronts and encourages migration from Aura-based B2B stores.

Migrating an Aura site usually means replacing Aura components with LWC, while many existing LWCs can be reused with few changes. The article advises inventorying components and dependencies, transferring storefront configuration, and testing the full user journey. It also recommends recording baseline performance with tools such as Lighthouse, WebPageTest and Core Web Vitals before and after migration.

Read the original at dev.to (opens in a new tab)

Worth reading?

Must-read

Avoiding runtime anti-patterns in Lightning Web Components (opens in a new tab)

You will learn why global DOM queries, ID selectors, setTimeout-based timing and early lifecycle access break LWC components, and the reliable alternatives for each.

Why read this

The piece closes a series, so the reader gets a complete set of runtime fixes.

Fragile timing workaround

  • setTimeout to wait for data
  • setTimeout(..., 0) after a property change
  • Guessed wall-clock delay

Reliable alternative

  • async and await for loaded data
  • renderedCallback after each render
  • Signal from the engine
Replacing timing workarounds with lifecycle-aware code makes updates reliable

This final post in a series on Lightning Web Component anti-patterns covers runtime mistakes in DOM access, asynchronous timing, the component lifecycle, performance, and base component usage. The article’s central point is that these bugs stem from wrong assumptions about when things happen, such as when the DOM exists, when a render has completed, and which runtime a component runs in.

On DOM access, the article warns against querying the global document, since Lightning Web Security scopes calls to the sandbox and tests may behave differently from production; it recommends scoping queries to the component’s template or using LWC:ref. It also warns against setting innerHTML, which carries XSS risk and conflicts with reactive rendering, recommending declarative markup and lightning-formatted-rich-text for trusted rich text. ID selectors are unreliable because LWC rewrites id attributes at render time, so class selectors, data attributes, or LWC:ref should be used instead. For timing, setTimeout should not be used to wait for async data (use async/await) or for re-renders (use renderedCallback, which runs after every render). For lifecycle, @api values are not readable in the constructor, DOM access fails in the constructor and connectedCallback because nothing has rendered yet, and this.template.children should be avoided in favour of stable selectors.

Performance guidance says that repeatedly crossing the Lightning Web Security proxy boundary becomes costly with large data: clone host data into local arrays once, push aggregation into Apex, and prefer plain objects and arrays over Set and Map for large collections. The base component section covers several silent failures: platformShowToastEvent does nothing outside Lightning Experience and mobile, so lightning/toast should be used; only lightning/modal and lightning/datatable support extension, so other components should be wrapped; the record ID should be read from the success event rather than from submit; internal SLDS shadow styles should not be overridden, and the public –slds- hooks used instead; and mobile support must be checked, since lightning-datatable fails silently in the Salesforce Mobile App and desktop responsive mode does not reliably reproduce this.

The conclusion ties the patterns together: LWC guarantees are narrower than they seem, and assuming readiness before it exists causes most of these problems. The article closes with a list of resources, including lifecycle documentation, LWC:ref, lightning/toast, @Salesforce/client/formFactor, and the LWC ESLint plugin rules.

Read the original at Salesforce Developers Blog (opens in a new tab)

Worth reading?

Must-read

Moving display logic from Apex into HXL widget formulas (opens in a new tab)

You will learn how to express conditional display, badge coloring, arithmetic and blank checks as formulas inside HXL widget JSON, what the formula functions can and cannot do, and why deployed widget schemas can only grow.

Before: Apex

  • Precomputes ratingVariant
  • Computes winRate in Apex
  • Sends hasPhone and hasOpenPipeline

After: widget formulas

  • CASE() picks the badge variant
  • IF() guards the win rate division
  • NOT(ISBLANK()) checks the phone
Display logic moves from the Apex DTO into the widget itself

HXL widgets are declarative JSON components, currently in beta, that can be embedded in Claude, ChatGPT and Agentforce. Their {!…} expressions can use math, comparison and logic operators and functions such as IF, CASE, AND and LEN, so display logic can sit beside the display rather than in Apex. The author shows an account card whose display fields were first precomputed in an Apex DTO and then replaced with formulas for visibility, badge variant, win rate and phone presence.

The author notes limits. There are no formatting functions for dates or currency, so those values still need formatting in Apex, and there is no aggregate such as SUM or AVERAGE across a list. Moving an existing widget also has a catch: a deployed schema.json can only grow, so removing old properties requires deploying a new widget bundle and repointing the Custom Lightning Type renderer.

The post also points to the Headless Experience Layer Playground for testing formulas live and to a formula reference in the Salesforce platform-widget-generate skill for coding agents.

Read the original at Salesforce Developers Blog (opens in a new tab)

Worth reading?

Must-read

Salesforce Multi-Framework now supports Angular, microfrontends, and Managed Packages (opens in a new tab)

Readers will learn how to build, embed, and distribute Angular applications directly on the Salesforce Platform using the new Multi-Framework runtime.

Why read this

The article also covers secure cross-app communication, localization, and enterprise authentication requirements.

Multi-Framework runtime capabilities

  • Angular framework support
  • Microfrontend embedding
  • Managed packages
  • Localization and internationalization
  • Multi-factor authentication
  • Multi-Framework Insights
The Winter '27 release introduces key enhancements to the Multi-Framework runtime

Salesforce Multi-Framework is a framework-agnostic runtime that lets developers run modern web apps directly on the Salesforce Platform, inheriting Salesforce authentication, security and governance without a separate hosting stack or manual token handling. After React reached general availability, the Winter ’27 release adds Angular as a second GA framework, with internal, external and basic templates, deployment as a UIBundle metadata type, and the same Data SDK and security model that React apps use. Internal apps run on the Salesforce.app domain, which isolates them from the Lightning runtime and from each other, while platform rules for object-level security, field-level security, sharing and validation continue to apply to data requests and saves.

Microfrontend is now generally available, allowing externally hosted React or Angular apps to be embedded in Lightning Experience, Experience Cloud, the Salesforce mobile app and Mobile Publisher apps without rebuilding them in Lightning Web Components. The lightning-ui-embedding component hosts the app in a sandboxed iframe and provides a two-way channel: hosts pass properties down and embedded apps send custom events back. Managed packages can now distribute non-site, employee-facing Multi-Framework apps together with their supporting metadata such as Permission Sets, Apex and Custom Objects, though site-based apps are not supported. The release also adds locale-aware formatting and localized labels through the Platform SDK and Data SDK, enterprise multi-factor authentication managed by Salesforce, and Multi-Framework Insights in Beta for performance and usage reporting.

The article also describes three ways to build these apps: Agentforce Vibes, now with Angular support and generally available, for code-first development; Builder Central in Beta for natural-language app creation by admins; and Quick Pages in Beta, where business users describe a page in plain language and get a data-driven page that respects the viewer’s security. Salesforce says Vue is the next UI framework planned, along with agentic experiences and Government Cloud support.

Read the original at Salesforce Developers Blog (opens in a new tab)

Worth reading?

Must-read

Using Microfrontends and UI Embedding to integrate external web apps into Lightning (opens in a new tab)

You will learn the architecture behind Salesforce Microfrontends, including how the Lightning host and embedded guest application communicate through UI Embedding.

Why read this

The article provides concrete code examples for building both the LWC host and a React-based guest app.

Microfrontend architecture

  • Lightning host
  • UI Embedding
  • Embedded web application
How Salesforce Microfrontends connect external apps to Lightning Experience

The article introduces Salesforce Microfrontends, which use UI Embedding to bring web applications built with React, Angular, Vue, or other standards-based technologies into Lightning pages alongside Lightning Web Components. The architecture has three parts: a Lightning host (a custom LWC that renders the lightning-ui-embedding base component and owns the Salesforce context and data), the embedded guest web application, and UI Embedding as the managed communication layer between them. The guest runs in a sandboxed iframe, which gives the two applications a browser-enforced isolation boundary. The host decides what information to share, and the external origin must be allowed in Salesforce security settings.

The article illustrates this with a ScoreAccount web app that shows an Account’s rating and lets users choose Hot, Warm, or Cold. The host retrieves the record data and passes the state to the guest, which renders it and subscribes to later updates. When the user selects a rating, the guest dispatches a score event that the host handles by updating the Salesforce record, and the host then sends any changed data back down. The article lists the four steps to bring such an app into Lightning: allow the origin, connect the guest to the UI Embedding channel through the Salesforce Platform SDK, create the host LWC, and deploy both sides through their own workflows. It presents the example in React but notes that the approach is not tied to one framework.

The piece argues that Microfrontends suit established web experiences that a team wants to keep on its own framework, infrastructure, and release cycle, such as an existing analytics app or internal search tool, rather than rebuilding them. It positions Microfrontends as complementary to LWC, which remains the native model for Salesforce-specific experiences, and to Salesforce Multi-Framework, where supported frameworks are packaged as UI bundles and hosted on Salesforce. A comparison table shows that externally hosted Microfrontends run on the team’s own infrastructure, while UI bundles are built and deployed through Salesforce workflows. The article gives UI Embedding’s status as GA since September 2026 and UI bundle embedding as in Beta with GA targeted for mid-November 2026, and it points readers to the UI Embedding recipes and Salesforce Developer documentation for implementation details.

Read the original at Salesforce Developers Blog (opens in a new tab)

Worth reading?