Is there a way directly return a value from a controller function which is invoked through aura:method?

Example: I have a "super" component with the following markup


    <aura:method name="getValue" action="{!c.onGetValue}" access="public" />


onGetValue : function(component, event, helper) 
    return 100;

In the application I instantiate the component and I want to call the public method like this


    <aura:handler name="init" value="{!this}" action="{!c.onInit}" />
    <c:SuperComp aura:id="myComp" />


onInit : function(component, event, helper)

Unfortunately the console output is always undefined (checked that getValue is invoked). So how can I get the value returned from the aura:method?

A workaround would be changing the definition of aura:method by adding an attribute which accepts a javascript callback function and call the callback, but that makes it not so reusable at all.

3 Answers 3


Methods in Lightning components do not return a value, also came to the same outcome as yourself.

However, I did learn to use and love component events with dynamic event handlers. What you can do from the calling component is fire a component event from within the component you wish to call the method on currently and attach a dynamic event handler for the component finishes processing.

So for example, you can fire an event from where you want to fire the method now like so:


Then also attach a dynamic event handler to listen for a response:

otherComponent.addHandler('responseEvent', component, 'c.handlingControllerAction');

The approach has the benefit of decoupling your components and if you need your other component to do asynchronous work then you can as also the response event would be fired asynchronously. It also allows multiple components to listen out for this event and also react accordingly.

Find more information on the Salesforce help:


Hope this helps!

  • Thank you Adam, I haven't thought about the dynamic event driven approach indeed - sounds good. Mar 21, 2016 at 10:10

+1 for Adam's repsonse.

Update: One can now use a return statement to pass back the desired response. Documentation: https://developer.salesforce.com/docs/atlas.en-us.210.0.lightning.meta/lightning/js_cmp_methods_sync.htm

Original: In Winter 18, the next Salesforce release coming in October, it will now allow Aura method's to return a value using return: Return a Result from aura:method

  • That's a great find. Thank you for your contribution!
    – sfdcfox
    Aug 28, 2017 at 17:11
  • Indeed very useful now. You can use promises with Aura Methods too.
    – Adam
    Apr 6, 2018 at 6:50

You can get return value using parameter. E.g. pass following parameter to the method:

var result = {};

onGetValue : function(component, event, helper) 
    var params = event.getParam('arguments');
    params.param['returnValue'] = 'hello world';

You must log in to answer this question.

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