Get Information About the Current Experience Builder Site

Import information about the current Experience Builder site from the @salesforce/community and @salesforce/site scoped modules.

If a component imports @salesforce/community or @salesforce/site, it can target only an Experience Builder page. You can’t use the component in any other Salesforce container. See Configure a Component for Experience Builder.

An Experience Builder site is composed of a Network object that contains administration settings, such as email and membership configurations, and a Site object that contains domain and page setting information. Using the @salesforce/community module, you can retrieve the ID of the network part of the site, whereas the @salesforce/site module lets you retrieve the ID of the site part.

Import the network ID and base path of the current Experience Builder site from @salesforce/community.

  • property—The supported properties are:

    • Id—The ID of the current site. For example, import the ID to pass as a parameter to an API.

    • basePath—The base path is the section of the site’s URL that comes after the domain. So if your site domain name is UniversalTelco.force.com and myPartnerSite was the URL value added when you created the site, the site's URL is UniversalTelco.force.com/myPartnerSite/s. In this case, myPartnerSite/s is the base path.

      For example, to build a link component that works across several sites, import the base path and use it to dynamically construct the full site URL.

  • propertyName—A name that refers to the imported Experience Builder property.

This sample code calls an Apex controller that returns all the feed items for the current site.

The Apex controller takes a community ID to ensure that the feed result is scoped to that site.

Import the site ID and the list of active languages of the current Experience Builder site from @salesforce/site.

  • property—The supported properties are:

    • Id—The ID of the current site. For example, import the ID to pass as a parameter to an API.
    • activeLanguages—The list of active languages in your Experience Builder site includes metadata on the default site language and all other active languages. You can configure a site’s languages in Experience Builder in Settings | Languages. Inactive languages are excluded from the list. The return value is an array of language objects, where each object includes the language’s label and the code, such as en-US. The array is sorted alphabetically by the label.
  • propertyName—A name that refers to the imported Experience Builder property.

This sample code uses activeLanguages in a language selector component.

The component displays a dropdown language picker using lightning-combobox.

See Also