7

All of the examples for Lightning Out, such as Use Lightning Components in Visualforce Pages shows that we need an app and a component. Is there a way to use just an app or just a component? Ideally, I'd like to just be able to write an App and not need the extra burden of a component as well.

Documented Example

<apex:page>
    <apex:includeLightning />

    <div id="lightning" />

    <script>
        $Lightning.use("c:lcvfTest", function() {
          $Lightning.createComponent("ui:button",
          { label : "Press Me!" },
          "lightning",
          function(cmp) {
            // do some stuff
          });
        });
    </script>
</apex:page>

Ideally, I'd prefer if I could just create the app itself in createComponent or something, so that I don't need to have a small three-line application bundle just for the sake of bootstraping a component.

3
  • I've tried a few different configurations. What I think is happening is that the use function explicitly replaces whatever is in the body of the app with the new content generated in createComponent. Commented May 25, 2017 at 22:12
  • @CasparHarmer Curiously, $Lightning.createComponent does create apps as well as components (which I proved via console logs), but I can't seem to get the app to render. Looks like I might have to deal with using both, but it seems like overkill, since we can't bundle components/apps together. We really need better source code organization. Apex Code has the same problem, but it seems like Lightning could have fixed this... and failed.
    – sfdcfox
    Commented May 28, 2017 at 5:07
  • 1
    I think we need both. For sure we need app, because the ltng:outApp is need to bring it outside lightning. Commented May 28, 2017 at 11:20

1 Answer 1

1

Yes, the small little Lightning app bundle is needed. Salesforce uses this "dependency app" to bundle all the transitive dependencies of the Lightning components.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .