How to use Lightning component into a Visualforce page
Sometimes, you might have a situation where you want to access your lightning component in the Salesforce classic view and here ltng:outApp comes into picture.
ltng:outApp : Is a component in the long namespace which is used to expose your lightning component outside of the lightning experience.
Sample Code
We need to wrap a component in a lightning app and make sure that lightning app is extending the ltng:outApp component. Look at the below sample code.
After creating the lightning app, we will have to create that lightning app in the VF page along with the lightning component in the script. In order to create these 2 resources, we will have to use apex:includeLightning tag.
apex:includeLightning – Includes the Lightning Components for Visualforce JavaScript library, lightning.out.js, from the correct Salesforce domain.
Look at the sample code which is creating the lightning app with it’s lightning component.
As you can see in the above code, we have defined a
We have managed to see the lightning component in the VF page and here is the output.
I am certified Salesforce Developer with Sales and Service cloud certifications. I am a true believer in #GivingBack principle and a Salesforce enthusiast. I am working as a member of our #SalesforceOhana to learn and help other fellow Trailblazers of the community to grow and learn.
“I’m a true believer in karma. You get what you give, whether it’s bad or good.”