Activity Forums Salesforce® Discussions How to use salesforce lightning component in Visualforce

  • Kumar

    Member
    December 29, 2016 at 2:07 pm

    Hi everyone,

    How can we use a lightning component in a visualforce page?

    Thanks

  • Satyakam

    Member
    January 3, 2017 at 8:35 am

    Hi Kumar,

    if you want to use lightning component in your visualforce page,you have to follow below steps:

    1-Create your component.

    2-Create your App.

    3-Create Vf page to put your App and Component.

    Component-

    <aura:component>

    // Code Here

    </aura:component>

    App-

    <aura:application access="GLOBAL" extends="ltng:outApp">
    </aura:application>

    Vf page-

    <apex:page standardController="Account" sidebar="false" showHeader="false">
    <apex:includeLightning />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <div id="vf-app">

    </div>
    <script>
    var accountId = "{!$CurrentPage.parameters.id}";
    console.log('::::'+accountId);
    $Lightning.use("c:YourApp", function() {
    $Lightning.createComponent(
    "c:YourComponent",
    { "AccountId" : accountId },
    "vf-app",
    function(cmp) {
    console.log("Component created!");
    console.log(cmp)
    });
    });
    </script>
    </apex:page>

    Hope this will help you.

    Thanks

  • Kumar

    Member
    January 3, 2017 at 2:01 pm

    Thanks!

Viewing 1 - 3 of 3 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos