The Mediator Pattern in LWC: How Sibling Components Really Communicate

By | January 21, 2026

Sibling component communication is one of the most confusing topics for developers working with Lightning Web Components (LWC). At first glance, it feels natural to expect sibling components to communicate directly with each other. When that doesn’t work, many developers immediately reach for Pub-Sub, often without fully understanding the long-term implications.

Salesforce encourages a more structured and scalable communication approach where the parent component acts as the coordinator. This design approach is known as the Mediator Pattern, and it is the recommended, enterprise-grade solution for sibling communication in LWC.

Let’s Learn with a Real-Time Example

Business Scenario

Imagine you are building a Lightning page that includes the following components:

  • Account List – Displays a list of Accounts
  • Account Details – Displays details of the selected Account

When a user selects an Account from the list, the Account Details component should update automatically.

Component Hierarchy
Component Hierarchy

Even though Account List and Account Details are sibling components, they cannot communicate directly. Instead, the parent component mediates the communication between them.

Step 1: Account List (Sibling A – Event Emitter)

The Account List component fires a custom event when an Account is selected.

accountList.js
accountList.js

Step 2: Parent Component – Mediator

The parent component listens to the custom event fired by the Account List component. It stores the selected Account Id and then passes that value down to the Account Details component.

parent.html
parent.html
parent.js
parent.js

This is the Mediator Pattern in action.
The parent:

  • Acts as the central coordinator
  • Maintains shared state
  • Controls data flow between sibling components

Step 3: Account Details (Sibling B – Consumer)

The Account Details component receives the Account Id from the parent using a public @api property.

accountDetails.js
accountDetails.js

Whenever the value changes in the parent, the Account Details component updates automatically.

This component:

  • Has no dependency on the Account List component
  • Remains reusable and testable
  • Automatically reacts to data changes

Why the Mediator Pattern Works So Well

The Mediator Pattern simplifies sibling communication by letting the parent component manage shared data. Sibling components remain independent, making the code easier to debug, extend, and reuse.

Because data flows in a single, predictable direction, applications built with this pattern are easier to scale and align perfectly with LWC best practices.

Conclusion

In Lightning Web Components, sibling components should never communicate directly with each other. All communication should flow through the parent component, which serves as the mediator.

By using:

  • Custom Events for child-to-parent communication
  • @api properties for parent-to-child data binding

Developers can create applications that are clean, maintainable, and scalable.

The Mediator Pattern is the recommended best practice for sibling communication in LWC and represents the gold standard for building robust, enterprise-grade component architectures in Salesforce.

By following the above blog instructions, you will be able to learn “The Mediator Pattern in LWC: How Sibling Components Really Communicate“. If you still have queries or any related problems, don’t hesitate to contact us at salesforce@greytrix.com. More details about our integration product are available on our website and Salesforce AppExchange.

We hope you may find this blog resourceful and helpful. However, if you still have concerns and need more help, please contact us at salesforce@greytrix.com.

About Us

Greytrix – a globally recognized and one of the oldest Sage Development Partner and a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners and Sage PSG across the globe. We offer Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that require apex code incorporation into the Salesforce platform.

Greytrix has some unique solutions for Cloud CRM such as Salesforce Sage integration for Sage X3, Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data Migration, Integrated App development, Custom App development and Technical Support business partners and end users. Salesforce Cloud CRM integration offered by Greytrix works with Lightning web components and supports standard opportunity workflow. Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star rated app listed on Salesforce AppExchange.
The GUMU™ Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for processing and execution of application programs at the click of a button.

For more information on our Salesforce products and services, contact us at salesforce@greytrix.com. We will be glad to assist you.

Related Posts