function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Amita Tatar 1Amita Tatar 1 

Lightning error $Lightning is not defined.

Hi guys! I have created a code in which i have embedded a lightning component inside visualforce page. But when i preview the code i get the error as  $Lightning is not defined. Can someone please help. 
My VF PAGE:
<apex:page sidebar="false" showHeader="false"> <!-- <apex:includeScript value="/lightning/lightning.out.js" /> --> <apex:includeScript value="{!$Site.BaseUrl}/lightning/lightning.out.js?v=2"/> <div id="lightning" /> <script> $Lightning.use("c:HelloApp",function(){ $Lightning.createComponent("c:Hello", {}, "lightning", function(cmp) { // do some stuff }); }); </script> </apex:page>

My App:

<aura:application access="GLOBAL" extends="ltng:outApp">
    
  <aura:dependency resource="c:Hello"></aura:dependency>
  
</aura:application>
Siva SakthiSiva Sakthi
Hi Amita,

Refer This Link  :  https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_visualforce.htm

You have missed the <apex:includeLightning /> in the VF Page. Try This hope this will help you.
<apex:page sidebar="false" showHeader="false"> 
<!-- <apex:includeScript value="/lightning/lightning.out.js" /> --> 
<apex:includeScript value="{!$Site.BaseUrl}/lightning/lightning.out.js?v=2"/> 
<apex:includeLightning />
<div id="lightning" /> 
<script> 
$Lightning.use("c:HelloApp",function(){ $Lightning.createComponent("c:Hello", {}, "lightning", function(cmp) {  stuff }); }); 
</script> 
</apex:page>

Thanks
Siva