I could not show the lightning app in a visual force page.

However, if I include weiParent2 component in the community lightning builder the component will show up.

What's the issue to use the lightning in a VF page?

Lightning Login App

<aura:application extends="ltng:outApp"
    <aura:dependency resource="c:weiParent2"/>
    <c:weiParent2 />

VF page


    Hello World Wei

<div id="lightning"/>

    $Lightning.use("c:lightningLoginApp", function () {
            {label: "This is the lightning button!"},
            function (cmp) {



  • 1
    you dont need to add <c:weiParent2 /> in your app, only declare it as a dependency and create it as you already are inthe vf pags script
    – glls
    Commented Jul 21, 2018 at 1:31
  • Your VF page doesn't really look like a VF page since there's not an <apex:page> tag. Commented Jul 21, 2018 at 1:34

1 Answer 1


Here's a pattern that I've been pretty successful with.

<apex:page sidebar="false">
    $Lightning.use("c:lightningLoginApp", function() {
          {label: "This is the lightning button!"},
          function(cmp) {
              console.log("Component created!");
              //debugger ?? what's this for?
  <div id="lightning"></div>
  • You need to include the lightning/lightning.out.js script
  • I think you want to have the div after your script.
  • Also glls' comment is, I think, relevant. The component you create dynamically probably shouldn't be in you app

Maybe refactoring to this pattern is worth a try.

  • 3
    newBike is using <apex:includeLightning/> which is the recommended way to include the lightning out runtime. Commented Jul 21, 2018 at 7:45
  • Hi @John if I want to re-render the component and the re-render event should be controlled by a parent container Visualforce page. How could I do that?
    – newBike
    Commented Jul 26, 2018 at 0:50
  • Checked it out... there's actually a couple of outdated references in the documentation, but <apex:includeLightning/> is certainly valid. I edited my answer. Commented Jul 27, 2018 at 14:43

You must log in to answer this question.

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