Configure Lightning Components for Community Builder

We will see here how to add the custom lightning component on to the community builder. To appear as a drag-and-drop component in Community Builder, a component must implement the forceCommunity:availableForAllPageTypes interface. After you create the Lightning component, it appears in the Components panel of all Lightning communities in your Org..

1.Create a Component 

Here’s the sample code for the custom component that will be used in the community builder.

Apex Class

Component (FirstCommunityCmp.cmp)

Styles

 

  • To make a resource, such as a component, usable outside of your own org, mark it with access=” global”.
  • When you add custom components to your community, they can bypass the object- and field-level security (FLS) you
    set for the guest user profile.
  • Lightning components don’t automatically enforce CRUD and FLS when referencing objects or retrieving the objects from an Apex controller. This means that the framework continues to display records and fields
  • You must manually enforce CRUD and FLS in your Apex controllers.

2. Add a Design Resource to  Component Bundle

A design resource controls which component attributes are exposed in Community Builder. The design resource lives in the same folder as your .cmp resource and describes the design-time behavior of the Lightning component—information that visual tools need to display the component in a page or app.

Here is the designer code

3. Add an SVG Resource to Component 

To define a custom icon for your component, add an SVG resource to the component bundle. The icon appears next to the component in the Community Builder Components panel. Here is the code for SVG

4. Drag and Drop the component to Community 

Now go the Salesforce community builder and drag and drop the component as shown below.

Configure the component attribute as shown below and publish your changes

After publishing the community you can able to see the basic information of the user as shown below.