Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Message Channel entry
How-to guide

How to create a Message Channel

You create a Message Channel as metadata in a Salesforce DX project, then deploy it so components can publish and subscribe. There is no point-and-click builder for the channel itself. You author the XML, save it in the right folder, and push it to the org.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated Jun 16, 2026

You create a Message Channel as metadata in a Salesforce DX project, then deploy it so components can publish and subscribe. There is no point-and-click builder for the channel itself. You author the XML, save it in the right folder, and push it to the org.

  1. Create the messageChannels folder

    In your Salesforce DX project, make sure the path force-app/main/default/messageChannels exists. This is where every Message Channel definition lives alongside the rest of your source.

  2. Add the channel file

    Create a file named for your channel using the format channelName.messageChannel-meta.xml, for example ContactSelected.messageChannel-meta.xml. The file name before the extension becomes the channel's API name.

  3. Declare the channel contract

    In the XML, set the masterLabel, an optional description, the isExposed flag, and one or more lightningMessageFields. Give each field a fieldName so publishers and subscribers know what the payload should contain.

  4. Deploy and reference it

    Deploy the metadata to your org. In a component, import the channel from @salesforce/messageChannel using its API name with the __c suffix, then call publish or subscribe from lightning/messageService.

Mandatory fields
masterLabelrequired

The human-readable label for the channel, shown where channels are listed. Required for a valid channel definition.

isExposedrequired

Boolean that decides whether components in other namespaces may use the channel. Defaults to false, which keeps the channel private to its own namespace.

lightningMessageFieldsrequired

One or more field entries, each with a fieldName, that document the shape of the message payload the channel carries.

Gotchas
  • Reference the channel with its __c suffix in the import, for example @salesforce/messageChannel/ContactSelected__c, or the import fails to resolve.
  • Leave isExposed at false unless another namespace truly needs the channel. Exposing it lets outside packages publish to and subscribe on it.
  • Always unsubscribe in disconnectedCallback. Subscriptions that are never cleaned up keep running and degrade page performance over time.
  • Scope can only be set on the subscriber, and only with @wire(MessageContext). You cannot scope a publisher.

See the full Message Channel entry

Message Channel includes the definition, worked example, deep dive, related terms, and a quiz.