{"id":1670,"date":"2026-09-22T13:00:00","date_gmt":"2026-09-22T07:30:00","guid":{"rendered":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/"},"modified":"2026-11-15T11:32:49","modified_gmt":"2026-11-15T06:02:49","slug":"lightning-message-service-lwc","status":"publish","type":"post","link":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/","title":{"rendered":"Lightning Message Service in LWC: Talk Across the Page"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Lightning Message Service lets components that are not parent and child send messages to each other on the same Lightning page or app. A course list in the main region and a detail panel in the utility bar share no common parent, but with Lightning Message Service, one can publish &#8220;course selected&#8221; and the other can react. It even works across LWC, Aura and Visualforce.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this post, you will learn message channels, how to publish and subscribe, why you must unsubscribe, and how scope works. It builds on <a href=\"https:\/\/swapnilzambare.com\/blog\/lwc-custom-events-child-to-parent\/\">LWC custom events<\/a>, <a href=\"https:\/\/swapnilzambare.com\/blog\/lwc-parent-to-child-api\/\">LWC parent to child communication<\/a> and the <a href=\"https:\/\/swapnilzambare.com\/blog\/salesforce-dx-project-structure\/\">Salesforce DX project structure<\/a>, where the channel file lives.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is Lightning Message Service?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Lightning Message Service (LMS) is a publish and subscribe service for the Lightning UI. You define a message channel as metadata, such as Course_Selected__c. A publisher sends a message on that channel, and every subscriber on the page receives it. Publishers and subscribers do not need to know about each other.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of a school notice board. A teacher pins a notice, and any student who checks the board sees it. The teacher does not need to know who reads it, and students do not need to know who wrote it. The message channel is the board.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Lightning Message Service Matters<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Events only travel up the component tree. Here is why Lightning Message Service matters at Bright Path Tutors.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, the course list and the course detail panel sit in different page regions.<\/li>\n\n<li>Also, a utility bar component must react to selections on the main page.<\/li>\n\n<li>Next, an old Visualforce page still needs to hear about selections.<\/li>\n\n<li>Publishers stay simple, because they do not track listeners.<\/li>\n\n<li>Finally, new subscribers can join without changing the publisher.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So LMS connects components that DOM events cannot reach.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Lightning Message Service Works<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Lightning Message Service follows a clear flow. First, you create a message channel file and deploy it. Next, each component imports the channel and gets a MessageContext with the wire service. Then subscribers call subscribe, usually in connectedCallback, and pass a handler. After that, the publisher calls publish with a message object, such as { courseId }. Finally, LMS delivers the message to every active subscriber on that channel, and each handler updates its component.<\/p>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-diagram-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-diagram-1-1024x640.png\" alt=\"Lightning Message Service diagram showing channel, context, subscribe, publish and deliver\" class=\"wp-image-1668\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-diagram-1-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-diagram-1-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-diagram-1-768x480.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">How a message reaches every subscriber.<\/figcaption><\/figure>\n\n\n<h3 class=\"wp-block-heading\">Message Channels<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A channel is a metadata file in the messageChannels folder, such as Course_Selected.messageChannel-meta.xml. It has a label, a description and optional field names.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Importing a Channel<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Components import a channel with <code>@salesforce\/messageChannel\/Course_Selected__c<\/code>. The __c suffix refers to the channel, not a custom object.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">MessageContext<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>@wire(MessageContext) messageContext;<\/code> gives the component the context it needs to publish and subscribe.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Publish<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">publish(this.messageContext, CHANNEL, message) sends a message to all subscribers.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Subscribe and Unsubscribe<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">subscribe returns a subscription. Call unsubscribe in disconnectedCallback, so the component stops listening when it leaves the page.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Scope<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">By default, subscribers receive messages only from the active area, such as the current console tab. Pass APPLICATION_SCOPE to receive messages from anywhere in the app.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Lightning Message Service Building Blocks<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below lists the pieces you import from lightning\/messageService.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Import<\/th><th>Purpose<\/th><\/tr><\/thead><tbody><tr><td>MessageContext<\/td><td>Wire adapter that provides the context<\/td><\/tr><tr><td>publish<\/td><td>Sends a message on a channel<\/td><\/tr><tr><td>subscribe<\/td><td>Starts listening on a channel<\/td><\/tr><tr><td>unsubscribe<\/td><td>Stops listening<\/td><\/tr><tr><td>APPLICATION_SCOPE<\/td><td>Listens across the whole app<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Custom Events vs Lightning Message Service<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below compares the two ways components talk.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Feature<\/th><th>Custom events<\/th><th>Lightning Message Service<\/th><\/tr><\/thead><tbody><tr><td>Who can listen<\/td><td>Parent, or ancestors with bubbles<\/td><td>Any subscriber on the page<\/td><\/tr><tr><td>Setup<\/td><td>No metadata<\/td><td>A message channel file<\/td><\/tr><tr><td>Works with Aura and Visualforce<\/td><td>Aura only, through markup<\/td><td>Yes, both<\/td><\/tr><tr><td>Coupling<\/td><td>Parent and child<\/td><td>None<\/td><\/tr><tr><td>Best for<\/td><td>Parent and child chains<\/td><td>Unrelated components<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When to use which is clear. Use custom events between a child and its parent. Use Lightning Message Service when components sit in different branches or regions.<\/p>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-diagram-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-diagram-2-1024x640.png\" alt=\"Lightning Message Service diagram comparing custom events and Lightning Message Service\" class=\"wp-image-1669\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-diagram-2-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-diagram-2-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-diagram-2-768x480.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Custom events vs Lightning Message Service.<\/figcaption><\/figure>\n\n\n<h2 class=\"wp-block-heading\">A Real Lightning Message Service Example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s use Lightning Message Service at Bright Path Tutors. A course list publishes the selected course, and a separate detail panel shows it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: The Message Channel<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;LightningMessageChannel xmlns=\"http:\/\/soap.sforce.com\/2006\/04\/metadata\"&gt;\n    &lt;masterLabel&gt;Course Selected&lt;\/masterLabel&gt;\n    &lt;isExposed&gt;true&lt;\/isExposed&gt;\n    &lt;description&gt;Sent when a user selects a course.&lt;\/description&gt;\n    &lt;lightningMessageFields&gt;\n        &lt;fieldName&gt;courseId&lt;\/fieldName&gt;\n        &lt;description&gt;Id of the selected course&lt;\/description&gt;\n    &lt;\/lightningMessageFields&gt;\n&lt;\/LightningMessageChannel&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save this as force-app\/main\/default\/messageChannels\/Course_Selected.messageChannel-meta.xml and deploy it. The field list documents the message shape.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: The Publisher<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>import { LightningElement, wire } from 'lwc';\nimport { publish, MessageContext } from 'lightning\/messageService';\nimport COURSE_SELECTED from '@salesforce\/messageChannel\/Course_Selected__c';\n\nexport default class CoursePicker extends LightningElement {\n    @wire(MessageContext) messageContext;\n\n    handleSelect(event) {\n        const courseId = event.currentTarget.dataset.id;\n        publish(this.messageContext, COURSE_SELECTED, { courseId });\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The picker wires a MessageContext and imports the channel. When a user clicks a course, it publishes the course Id.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: The Subscriber<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>import { LightningElement, wire } from 'lwc';\nimport { subscribe, unsubscribe, MessageContext, APPLICATION_SCOPE }\n    from 'lightning\/messageService';\nimport COURSE_SELECTED from '@salesforce\/messageChannel\/Course_Selected__c';\n\nexport default class CourseDetailPanel extends LightningElement {\n    @wire(MessageContext) messageContext;\n    subscription = null;\n    courseId;\n\n    connectedCallback() {\n        this.subscription = subscribe(this.messageContext, COURSE_SELECTED,\n            (message) =&gt; { this.courseId = message.courseId; },\n            { scope: APPLICATION_SCOPE });\n    }\n\n    disconnectedCallback() {\n        unsubscribe(this.subscription);\n        this.subscription = null;\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The panel subscribes when it connects and stores the received Id. Then it unsubscribes when it leaves the page. APPLICATION_SCOPE lets it hear messages even from the utility bar or another tab area.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: See It Work<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here is what the panel shows after Asha clicks SOQL Basics in the picker.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Course Detail Panel\nSelected course: a01B<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The two components share no parent, yet the panel updated as soon as the message arrived.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Lightning Message Service in Aura and Visualforce<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Aura components use the lightning:messageChannel tag to publish and subscribe. Visualforce pages use the sforce.one.publish and sforce.one.subscribe functions with the channel&#8217;s API name. So older parts of the org can join the same conversation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with Lightning Message Service<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Forgetting to unsubscribe in disconnectedCallback.<\/li>\n\n<li>Subscribing more than once, which runs the handler twice.<\/li>\n\n<li>Forgetting to deploy the message channel file.<\/li>\n\n<li>Sending large records instead of Ids.<\/li>\n\n<li>Using LMS between a direct parent and child, where events are simpler.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for Lightning Message Service<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Name channels after business events, such as Course_Selected.<\/li>\n\n<li>Send small messages, such as Ids, and load data in the subscriber.<\/li>\n\n<li>Subscribe once and always unsubscribe on disconnect.<\/li>\n\n<li>Use APPLICATION_SCOPE only when you need app-wide messages.<\/li>\n\n<li>Document each channel&#8217;s fields in the metadata file.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Practice Task<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Add a second subscriber that counts how many times a course was selected in this session. Hint: subscribe to the same channel and add 1 to a counter field in the handler.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Most Asked Interview Questions on Lightning Message Service<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">LMS questions show up whenever interviewers ask about component communication. Here are the 21 questions asked most about Lightning Message Service.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Basic Questions on Lightning Message Service<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1: What is Lightning Message Service?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A publish and subscribe service that lets components on a Lightning page talk without a parent and child link.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2: What is a message channel?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A metadata file that defines a named channel, such as Course_Selected__c.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3: Where do message channel files live?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the messageChannels folder of the project.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q4: How do you publish a message?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Call publish with the MessageContext, the channel and a message object.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q5: How do you subscribe?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Call subscribe with the MessageContext, the channel and a handler function.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q6: Why unsubscribe?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because otherwise the handler may keep running after the component leaves the page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q7: Which technologies can use LMS?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">LWC, Aura and Visualforce on Lightning pages.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Code and Scenario Questions on Lightning Message Service<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q8: How do you get a MessageContext?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use @wire(MessageContext) messageContext in the component.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q9: How do you import a channel?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Import it from @salesforce\/messageChannel\/ChannelName__c.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q10: What does APPLICATION_SCOPE do?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It lets a subscriber receive messages from anywhere in the app, not only the active area.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q11: Where should you subscribe?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Usually in connectedCallback, after checking you are not already subscribed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q12: What should a message contain?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Small data, such as record Ids, so subscribers can load details themselves.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q13: How does an Aura component use LMS?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With the lightning:messageChannel component in its markup.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q14: Can LMS replace parent and child events?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It can, but events are simpler for direct parent and child links.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Advanced Questions on Lightning Message Service<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q15: What happens if you subscribe twice?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The handler runs twice for each message, so guard against double subscriptions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q16: Does LMS work across browser tabs?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No, because it works within one Lightning page or app in one tab.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q17: How is LMS different from platform events?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">LMS works in the browser UI, while platform events travel through the server event bus.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q18: Can Experience Cloud sites use LMS?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Some site types support it, so check the current docs for your site template.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q19: Why make the channel isExposed true?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So components in other namespaces, such as packages, can use it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q20: How do you test LMS in Jest?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use the mocks from sfdx-lwc-jest and assert publish was called with the right data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q21: How do you design channels for a large app?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use few, well-named channels with clear message shapes, documented in metadata.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/platform\/lwc\/guide\/use-message-channel-intro.html\" target=\"_blank\" rel=\"noopener noreferrer\">Communicate Across the DOM with Lightning Message Service (LWC Developer Guide)<\/a><\/li>\n\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/platform\/lwc\/guide\/use-message-channel-subscribe.html\" target=\"_blank\" rel=\"noopener noreferrer\">Subscribe to a Message Channel (LWC Developer Guide)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Lightning Message Service connects components without a parent and child link.<\/li>\n\n<li>A message channel file defines the channel.<\/li>\n\n<li>Publishers call publish, and subscribers call subscribe with a handler.<\/li>\n\n<li>Always unsubscribe in disconnectedCallback.<\/li>\n\n<li>APPLICATION_SCOPE extends listening to the whole app.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now let&#8217;s load real records without Apex. Next, read our guide to <a href=\"https:\/\/swapnilzambare.com\/blog\/lightning-data-service-lwc\/\">Lightning Data Service in LWC<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lightning Message Service lets components that are not parent and child send messages to each other on the same Lightning page or app. A&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1667,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[245,8,96],"tags":[26,113],"swapz_series":[],"class_list":["post-1670","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-lightning-web-components","category-salesforce","category-salesforce-developer","tag-intermediate","tag-lwc"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Lightning Message Service in LWC Explained<\/title>\n<meta name=\"description\" content=\"Lightning Message Service explained simply: message channels, publish, subscribe, MessageContext, scope, Aura and Visualforce and 21 interview Q&amp;A.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Lightning Message Service in LWC Explained\" \/>\n<meta property=\"og:description\" content=\"Lightning Message Service explained simply: message channels, publish, subscribe, MessageContext, scope, Aura and Visualforce and 21 interview Q&amp;A.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/\" \/>\n<meta property=\"og:site_name\" content=\"Swapnil Zambare - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-22T07:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-15T06:02:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Swapnil Zambare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Swapnil Zambare\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lightning-message-service-lwc\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lightning-message-service-lwc\\\/\"},\"author\":{\"name\":\"Swapnil Zambare\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/10b09224c8bcc562716e86789427592a\"},\"headline\":\"Lightning Message Service in LWC: Talk Across the Page\",\"datePublished\":\"2026-09-22T07:30:00+00:00\",\"dateModified\":\"2026-11-15T06:02:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lightning-message-service-lwc\\\/\"},\"wordCount\":1501,\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lightning-message-service-lwc\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/lightning-message-service-lwc-featured.png\",\"keywords\":[\"Intermediate\",\"LWC\"],\"articleSection\":[\"Lightning Web Components\",\"Salesforce\",\"Salesforce Developer\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lightning-message-service-lwc\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lightning-message-service-lwc\\\/\",\"name\":\"Lightning Message Service in LWC Explained\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lightning-message-service-lwc\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lightning-message-service-lwc\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/lightning-message-service-lwc-featured.png\",\"datePublished\":\"2026-09-22T07:30:00+00:00\",\"dateModified\":\"2026-11-15T06:02:49+00:00\",\"description\":\"Lightning Message Service explained simply: message channels, publish, subscribe, MessageContext, scope, Aura and Visualforce and 21 interview Q&A.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lightning-message-service-lwc\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lightning-message-service-lwc\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lightning-message-service-lwc\\\/#primaryimage\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/lightning-message-service-lwc-featured.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/lightning-message-service-lwc-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Lightning Message Service featured image: title card with an LWC code example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/lightning-message-service-lwc\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Lightning Message Service in LWC: Talk Across the Page\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"name\":\"Swapnil Zambare - Blog\",\"description\":\"Salesforce &amp; Tech Guides\",\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\",\"name\":\"Swapnil Zambare - Blog\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"width\":512,\"height\":512,\"caption\":\"Swapnil Zambare - Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/theSwapnilZambare\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/10b09224c8bcc562716e86789427592a\",\"name\":\"Swapnil Zambare\",\"sameAs\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\"],\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/author\\\/swapnil-zambare\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Lightning Message Service in LWC Explained","description":"Lightning Message Service explained simply: message channels, publish, subscribe, MessageContext, scope, Aura and Visualforce and 21 interview Q&A.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/","og_locale":"en_US","og_type":"article","og_title":"Lightning Message Service in LWC Explained","og_description":"Lightning Message Service explained simply: message channels, publish, subscribe, MessageContext, scope, Aura and Visualforce and 21 interview Q&A.","og_url":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/","og_site_name":"Swapnil Zambare - Blog","article_published_time":"2026-09-22T07:30:00+00:00","article_modified_time":"2026-11-15T06:02:49+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-featured.png","type":"image\/png"}],"author":"Swapnil Zambare","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Swapnil Zambare","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/#article","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/"},"author":{"name":"Swapnil Zambare","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/10b09224c8bcc562716e86789427592a"},"headline":"Lightning Message Service in LWC: Talk Across the Page","datePublished":"2026-09-22T07:30:00+00:00","dateModified":"2026-11-15T06:02:49+00:00","mainEntityOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/"},"wordCount":1501,"publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-featured.png","keywords":["Intermediate","LWC"],"articleSection":["Lightning Web Components","Salesforce","Salesforce Developer"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/","url":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/","name":"Lightning Message Service in LWC Explained","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/#primaryimage"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-featured.png","datePublished":"2026-09-22T07:30:00+00:00","dateModified":"2026-11-15T06:02:49+00:00","description":"Lightning Message Service explained simply: message channels, publish, subscribe, MessageContext, scope, Aura and Visualforce and 21 interview Q&A.","breadcrumb":{"@id":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/#primaryimage","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-featured.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/lightning-message-service-lwc-featured.png","width":2400,"height":1260,"caption":"Lightning Message Service featured image: title card with an LWC code example"},{"@type":"BreadcrumbList","@id":"https:\/\/swapnilzambare.com\/blog\/lightning-message-service-lwc\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swapnilzambare.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Lightning Message Service in LWC: Talk Across the Page"}]},{"@type":"WebSite","@id":"https:\/\/swapnilzambare.com\/blog\/#website","url":"https:\/\/swapnilzambare.com\/blog\/","name":"Swapnil Zambare - Blog","description":"Salesforce &amp; Tech Guides","publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swapnilzambare.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/swapnilzambare.com\/blog\/#organization","name":"Swapnil Zambare - Blog","url":"https:\/\/swapnilzambare.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","width":512,"height":512,"caption":"Swapnil Zambare - Blog"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/in\/theSwapnilZambare"]},{"@type":"Person","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/10b09224c8bcc562716e86789427592a","name":"Swapnil Zambare","sameAs":["https:\/\/swapnilzambare.com\/blog"],"url":"https:\/\/swapnilzambare.com\/blog\/author\/swapnil-zambare\/"}]}},"_links":{"self":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/comments?post=1670"}],"version-history":[{"count":1,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1670\/revisions"}],"predecessor-version":[{"id":2320,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1670\/revisions\/2320"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media\/1667"}],"wp:attachment":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media?parent=1670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/categories?post=1670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/tags?post=1670"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=1670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}