Fire Events From Lightning Component and Handle in VisualForce Page

Lightning Event:

<aura:event type="APPLICATION" description="Sample Event">
    <aura:attribute type="string" name="msg" />

Lightning Component:

<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable" access="global">
    <!--Declare Aura Event-->
    <aura:registerEvent name="sampleEvent" type="c:SampleEvent" />
    <!--Component Start--> 
    <div class="slds-m-around_xx-large">
        <lightning:button variant="Brand" class="slds-button" label="Submit" onclick="{!c.doAction}"/>
    <!--Component End-->

Lightning Controller:

    doAction : function(component, event, helper) {
        //Get Event
        var sampleEvent = $A.get("e.c:sampleEvent");
        //Set Parameter Value
        sampleEvent.setParams({"msg":"Hello World!!"});
        //Fire Event;

Lightning App:

<aura:application extends="ltng:outApp" access="global">
    <!--Lightning component-->
    <aura:dependency resource="c:SampleComponent"/>

Visualforce Page:

<apex:page sidebar="false" showHeader="false">
    <apex:includeLightning />
    <!--Lightning Container-->
    <div style="width:100%;height:100px;" id="LightningContainer" />
    <script type="text/javascript">
    //Create Lightning Component
    $Lightning.use("c:SampleApp", function() {
        $Lightning.createComponent("c:SampleComponent", { },"LightningContainer",
                                   function(component) {
                                       $A.eventService.addHandler({ "event": "c:SampleEvent", "handler" : getMessage});
    //Function to call Lightning Component Function
    var getMessage  = function(event){
        var msg = event.getParam("msg");


  • Satish Inuganti

    Hi Biswajeet,

    I’m also using the same technique. but event Handler is not getting invoked in VF after I raised the event from Aura Component. Not sure what is the issue. could you please help me ?

  • Bips SV

    thanks! it worked
    you are hero!

  • Ashok

    Thank you Biswajeet but i am facing below error.
    This page has an error. You might just need to refresh it. Action failed: c:myComponent$controller$doAction [Cannot read property ‘setParams’ of undefined] Failing descriptor: {c:myComponent$controller$doAction}