Lightning Web Components available in Community Builder

I understand that Lightning Web Components (LWC) are supported within Community/Digital Experience, but I cannot find a way to get the component in the Builder. Is there any special configuration param to include similar for how Aura/Lightning Components used:

implements="forceCommunity:availableForAllPageTypes" access="global"?

Answer

Yes, you have to handle it differently. For LWC in the community we have to edit the configuration file named as file—<component>.js-meta.xml

**

To make your component available in the Components tab in Community
Builder, define lightningCommunity__Page in targets. Without this tag,
your component can’t appear in Community Builder.

**

Config file Code:

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="helloWorld">
    <apiVersion>45.0</apiVersion>
    <isExposed>true</isExposed>
    <masterLabel>Hello World</masterLabel>
    <targets>
        <target>lightningCommunity__Page</target>
        <target>lightningCommunity__Default</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightningCommunity__Default">
            <property name="string" type="String" default="jsMetaValue"></property>
            <property name="boolean" type="Boolean" default="true"></property>
            <property name="integer" type="Integer" default="5"></property>
            <property name="picklist" type="String" default="value3" datasource="value1,value2,value3" />
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

SRC: https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.use_config_for_community_builder

Attribution
Source : Link , Question Author : Laurent P. , Answer Author : Pranay Jaiswal

Leave a Comment