Tuesday, February 8, 2022

How to Retrieve the info about Lightning Community in LWC

 Hello Friends today we are going to discus how to get Lighting community details in to LWC.

we can use the @salesforce/community module  in to Lightning web components for Lightning communities.

it help to provide information about the current community context with in LWC, let see by some of the Example.

Example 1:-

Use @salesforce/community/Id to import the ID of the current community

use case, when your component must pass the community ID as a parameter to an API.

syntax :-

import communityId from ‘@salesforce/community/Id’;

Example 2:-

Use @salesforce/community/basePath to import the base URL of your community

Use case, when building a link component that works across several communities.
syntax :-
import communityBasePath from ‘@salesforce/community/basePath’;