LightningMessageChannel defines a secure channel for Lightning Message Service, which lets Lightning web components, Aura components, and Visualforce pages communicate across UI technologies. The metadata identifies the channel and describes its message payload. Publisher and subscriber code determines when messages are sent and how they are handled.
A channel is not a Platform Event definition, and its payload fields are not independently deployed CustomField components. Its exposure setting also has packaging consequences: making a channel available across namespaces can prevent you from restricting it later.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
The metadata component's identity, inherited from Metadata. Do not confuse it with the displayed masterLabel when checking consumer references. |
masterLabel |
Required label for the channel. Changing the label is not a correction for an incorrectly named consumer import. |
isExposed |
Whether components in other namespaces can use the channel. Allowed values are true and false; the default is false. This setting affects Visualforce access, managed packaging, and whether exposure can later be restricted. |
description |
Describes the channel's purpose. A nested description in a payload-field definition describes that field. Neither establishes how consumer code actually handles messages. |
lightningMessageFields |
A list of nested LightningMessageField definitions describing the message payload. Use this exact capitalization in XML. |
fieldName |
Required unique identifier within each LightningMessageField definition. It names a payload field; a name such as recordId does not by itself establish a dependency on an object field. |
Behavior and Constraints
Exposure is a compatibility decision
isExposed controls access from components in other namespaces. Once it is true, it cannot later be changed to false for channels in managed packages or channels referenced by other components. Enabling exposure to solve a consumer-access problem can therefore prevent later restriction.
The documented packaging requirements create a specific limitation for Visualforce:
- A channel must have
isExposedset tofalseto pass the AppExchange Security Review. - Visualforce supports only channels with
isExposedset totrue. - Consequently, a managed package using a Lightning Message Channel in Visualforce cannot satisfy that security-review requirement. See the Visualforce considerations and limitations.
The declaration does not implement message handling
The channel and its nested payload definitions describe the intended message contract. They do not prove that a component publishes, subscribes, or handles a particular field. Those operations are implemented in consumer code. Lightning Message Service supports communication between UI components, as described in Communicate Across the DOM with Lightning Message Service.
Do not treat the declaration as an Apex object or Platform Event. In a reported deployment-callback implementation, attempting to instantiate the channel as an Apex __e or __c type failed. The recommended server-originated notification design used a separately defined Platform Event with EventBus.publish.
Deployment and Retrieval
Metadata API components use the .messageChannel suffix and the messageChannels directory. In Salesforce source format, a channel file uses a name such as force-app/main/default/messageChannels/Account_Selected.messageChannel-meta.xml.
The package.xml manifest supports the wildcard member * for the type name LightningMessageChannel. This lets a manifest select all channels for retrieval. See the LightningMessageChannel metadata reference.
When a consuming component reports that it cannot retrieve metadata for a channel descriptor, distinguish these two causes:
-
The channel exists, but the consumer reference is wrong. In the reported
Account_Selectedcase, the LWC import needed@salesforce/messageChannel/Account_Selected__c, not@salesforce/messageChannel/Account_Selected_c. The difference was the double underscore beforec, not the channel label. -
The channel definition never deployed. XML element names are case-sensitive. A report using
LightningMessageFieldsinstead oflightningMessageFieldsidentified the capitalization error as preventing channel deployment, leaving the consumer unable to resolve it.
Neither cause explains every descriptor lookup error. A separate packaging-only report involved a channel with isExposed set to false that worked during development; that report did not establish a fix or a general incompatibility with Aura and LWC consumers.
For removal, a community report describes successful CLI source deletion by targeting the channel's exact, case-sensitive .messageChannel-meta.xml filename. That report does not establish that every referenced or packaged channel can be deleted under the same conditions.
Relationships
Channel dependencies require source inspection. Incoming references can be embedded in component code or markup, but those references identify potential consumers, not confirmed runtime subscriptions. The nested LightningMessageField definitions belong to the channel rather than forming independently deployed assets.
References
-
CustomField:fieldName. This is a possible association, not an automatic dependency. The defined role offieldNameremains a payload-field identifier; inspect the actual source to determine whether an object-field association applies.
Referenced By
-
ApexComponent:filedata. -
ApexPage:filedata. -
LightningBundle:filedata. -
LightningWebComponent:filedata.
Reported Issues
-
A deployed channel can still produce a descriptor lookup error. In a 2021 LWC report, correcting
@salesforce/messageChannel/Account_Selected_cto@salesforce/messageChannel/Account_Selected__cfixed the reference. Incorrect import suffix report. -
A consumer lookup error can be a consequence of failed channel deployment. In a 2024 report, the response identified
LightningMessageFieldsas invalid capitalization and specifiedlightningMessageFields. The channel had not deployed, so the consumer could not resolve it. XML capitalization report. -
Apex cannot instantiate a channel merely by adding an object suffix. In December 2024, an Apex deployment-callback implementation failed when it treated a channel as a
__eor__ctype. The answer recommended a separate Platform Event forEventBus.publish. Apex publishing discussion. -
Successful deployment does not prove that messages will reach subscribers. In a 2022 LWC report, the publisher passed
this.MessageContextinstead of the wired propertythis.messageContext. The author reported that correcting the capitalization resolved delivery. Message context typo report. -
A channel lookup failure was reported only during managed-package creation. In 2025, a channel used by Aura and LWC components worked in development with
isExposedset tofalse, but packaging failed to find it. The report has no answer establishing a cause or workaround; it does not prove that unexposed channels are generally incompatible with those consumers. Unresolved packaging lookup report. -
An editor XML warning may not be a deployment failure. In a 2020 discussion, a response attributed a missing declaration warning for
LightningMessageChannelto an editor extension's XML validation and reported that the file could still be saved and deployed. Editor validation discussion. - CLI source deletion was reported as successful. A 2021 response described deleting a channel by its source-file path and emphasized matching the exact filename, including case. Channel deletion discussion.
Common Questions
Why does my LWC say it cannot retrieve metadata for a Lightning Message Channel?
Reported causes include an incorrect consumer import and a channel definition that never deployed. Check the double underscore in a reference such as Account_Selected__c and the exact XML element name lightningMessageFields. These are examples, not an exhaustive diagnosis.
How do I retrieve all Lightning Message Channels?
Use LightningMessageChannel as the type name and * as the member in package.xml. This metadata type supports wildcard selection.
Can I change isExposed from true back to false?
Not for a channel in a managed package or one referenced by other components. In those conditions, setting isExposed to true prevents a later change to false.
Can I publish to a Lightning Message Channel from Apex using EventBus.publish?
A Lightning Message Channel is not a Platform Event definition. The reported Apex implementation failed when it treated the channel as an event object; the recommended approach used a separately defined Platform Event with EventBus.publish.
Does a payload field named recordId create a CustomField dependency?
No dependency follows from that name alone. fieldName identifies a message payload field. Inspect the actual source before treating it as a reference to CustomField.