Newer Version Available

This content describes an older version of this product. View Latest

Create Multiple Components on a Web Page with Lightning Out

Lightning Out allows you to create Salesforce components outside of the Salesforce domain.

To create these components with Lightning Out on the same web page as an Embedded Service component, use "embeddedService:sidebarApp" as your application tag in your call to $Lightning.use.

In this code sample, we create a `HelloWorldComp` component in the body of the HTML document where an Embedded Service component is rendered.

Component Code

1$Lightning.use(
2    "embeddedService:sidebarApp",
3    function () {
4        $Lightning.createComponent(
5            "c:HelloWorldComp",
6            { … },
7            document.body,
8            function (cmp) {
9                console.log("callback");
10            }
11        );
12    },
13    “communityEndpointUrl”,
14    ...
15);