[SalesForce] Not able to display Lightning component in Sites

Based on latet Spring 17 release notes,
https://releasenotes.docs.salesforce.com/en-us/spring17/release-notes/rn_lightning_apps_public.htm

I am trying to display lightning component in sites. I have a sample lightning component, visualforce page showing the component and a public site. Visualforce page is added to the site. When I preview the site as admin, nothing is shown on the visualforce page and it is blank.

Below is my sample

App

<aura:application access="GLOBAL" extends="ltng:outApp" implements="ltng:allowGuestAccess">
    <aura:dependency resource="c:mySampleComponent"/>
</aura:application>

Component

<aura:component >
    <ui:outputText value="This is a sample lightning component" />        
</aura:component>

Visualforce Page

<apex:page showHeader="false" sidebar="false">
    <apex:includeLightning />


    <div id="lightningComp"/>
    <script>
        $Lightning.use("c:mySampleApp", function() {
          $Lightning.createComponent("c:mySampleComponent",
          { },
          "lightningComp",
          function(cmp) {
            // do some stuff
          });
        },'SITE URL GOES HERE'

      );

    </script>

</apex:page>

Any insight on this would be very helpful.

Best Answer

You will need to enable Salesforce communities to get it working .The docs clearly mentions that for lightning out to work for guest users you need Salesforce communities enabled .

Also any error will show up in browser console .Open console and look for errors .

Related Topic