The markup and JavaScript functions in the Lightning Out library are the only things specific to Lightning Out. Everything else is the Lightning components code you already know and love.
<script src="https://myDomain.my.salesforce.com/lightning/lightning.out.js"></script>
Load and initialize the Lightning Component framework and your Lightning components app with the $Lightning.use() function.
Name | Type | Description |
---|---|---|
appName | string | Required. The name of your Lightning dependency app, including the namespace. For example, "c:expenseAppDependencies". |
callback | function | A function to call once the Lightning Component framework
and your app have fully loaded. The callback receives no arguments. This callback is usually where you call $Lightning.createComponent() to add your app to the page (see the next section). You might also update your display in other ways, or otherwise respond to your Lightning components app being ready. |
lightningEndPointURI | string | The URL for the Lightning domain on your Salesforce instance. For example, “https://myDomain.lightning.force.com”. |
authToken | string | The session ID or OAuth access token for a valid, active Salesforce session. |
appName is required. The other three parameters are optional. In normal use you provide all four parameters.
Add to and activate your Lightning components on the page with the $Lightning.createComponent() function.
Name | Type | Description |
---|---|---|
componentName | string | Required. The name of the Lightning component to add to the page, including the namespace. For example, "c:newExpenseForm". |
attributes | Object | Required. The attributes to set on the component when it’s created. For example, { name: theName, amount: theAmount }. If the component doesn’t require any attributes, pass in an empty object, { }. |
domLocator | Element or string | Required. The DOM element or element ID that indicates where on the page to insert the created component. |
callback | function | A function to call once the component is added to and active on the page. The callback receives the component created as its only argument. |
Behind the scenes $Lightning.createComponent() calls the standard $A.createComponent() function. Except for the DOM locator, the arguments are the same. And except for wrapping the call in some Lightning Out semantics, the behavior is the same, too.