The JavaScript code to create a Lightning Component on a Visualforce page is as follows:
<apex:page> <apex:includeLightning /> <div id="Lightning" /> <script> $Lightning.use("c:youtubesearchOutApp", function() { $Lightning.createComponent("c:youtubesearch", { }, "Lightning", function(cmp) { // do some stuff }); }); </script></apex:page>
Notice that $Lightning.use() accepts two parameters:
- The name of the Lightning Out dependency application, along with its namespace.
- A callback function. The callback function receives no arguments. This callback is usually where you call $Lightning.createComponent() to add your app to the page (see the next section, Lightning Out in a Node.js ...