+ Start a Discussion

Lightning Out Apps with Non-Authenticated Users

I see that you have to have communities enabled in order to make a Lightning Out app/component available to non-authenticated users.  

Does ayone know if there are any plans to make this feature usable for orgs that don't have Communities?  Perhaps utilizing sites?
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Mellycooks,
I hope it will be helpful.

Please mark it as best answer if the information is informative.


NagendraNagendra (Salesforce Developers) 
Hi Mellycooks,

Add the ltng:allowGuestAccess interface to your Lightning Out dependency app to make it available to users without requiring them to authenticate with Salesforce. This interface lets you build your app with Lightning components, and deploy it anywhere and to anyone.

A Lightning Out dependency app with the ltng:allowGuestAccess interface can be used with Lightning Components for Visualforce and with Lightning Out.

Using Lightning Components for Visualforce, you can add your Lightning app to a Visualforce page, and then use that page in Salesforce Tabs + Visualforce communities. Then you can allow public access to that page.
Using Lightning Out, you can deploy your Lightning app anywhere Lightning Out is supported—which is almost anywhere!

The ltng:allowGuestAccess interface is only usable in orgs that have Communities enabled, and your Lightning Out app is associated with all community endpoints that you’ve defined in your org.

To begin with, add the ltng:allowGuestAccess interface to your Lightning Out dependency app. For example:
<aura:application access="GLOBAL" extends="ltng:outApp" 
 <aura:dependency resource="c:storeLocatorMain"/>
Next, add the Lightning Out JavaScript library to your page.
  • With Lightning Components for Visualforce, simply add the <apex:includeLightning /> tag anywhere on your page.
  • With Lightning Out, add a <script> tag that references the library directly, using a community endpoint URL. For example:
<script src="https://yourCommunityDomain/communityURL/lightning/lightning.out.js"></script>
For example, Finally, add the JavaScript code to load and activate your Lightning app. This code is standard Lightning Out, with the important addition that you must use one of your org’s community URLs for the endpoint. The endpoint URL takes the form https://yourCommunityDomain/communityURL/. The relevant line is emphasized in the following sample.
    $Lightning.use("c:locatorApp",    // name of the Lightning app
        function() {                  // Callback once framework and app loaded
                "c:storeLocatorMain", // top-level component of your app
                { },                  // attributes to set on the component when created
                "lightningLocator",   // the DOM location to insert the component
                function(cmp) {
                    // callback when component is created and active on the page
        'https://universalcontainers.force.com/ourstores/'  // Community endpoint
Note: You can only add the ltng:allowGuestAccess interface to Lightning apps, not to individual components.

Please mark this as solved if the information helps so that it results in helping others who are encountering a similar issue.

Best Regards,