How to create a MessageChannel in Salesforce using VS Code?

To create a MessageChannel, use the below steps

1. Open VS Code.

2. Create a Folder with the name "messageChannels" under force-app\main\default.

3. Create a file with Channel name followed by suffix ".messageChannel-meta.xml".

4. Add the below content(Change the variable names and add/remove as needed).

Sample Code:
<?xml version="1.0" encoding="UTF-8"?>
<LightningMessageChannel xmlns="">
    <description>This is a sample Lightning Message Channel.</description>
        <description>Variable 1</description>
        <description>Variable 2</description>

5. Add the below in your package.xml.


6. Deploy the MessageChannel to the Source Org by selecting SFDX: Deploy this Source to Org.


  1. hi!
    when i created message channel its throwing error "cannot find the declaration of element lightningmessagechannel. i added in package.xml but even though i'm getting this error..
    can you please help

    1. In VS Code, go to File => Preference => Settings => (search for) Validation ==> Click on XML and uncheck "Validation"

    2. i m trying same but it not working