---
schema_version: "1"
id: 35cdd990bf3a0b80c144ec89ba16a28c779ad45b8291e5a0a22b98e020730248
title: Calling Component Methods
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/aura-platform/guides/aura/js/js-cmp-methods.md
canonical_url: https://developer.salesforce.com/docs/platform/aura-platform/guide/js-cmp-methods.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 246c2004bf45307f330c7e4141640fc8dd0a73a874ef5e9b548245d5204dc7d5
products:
  - Lightning Aura Components Developer Guide
  - Platform Developer Content
---

# Calling Component Methods

Use `<aura:method>` to define a method as part of a component's API. This enables you to directly call a method in a component’s client-side controller instead of firing and handling a component event. Using `<aura:method>` simplifies the code needed for a parent component to call a method on a child component that it contains.

## Communicate Between Components

Use `aura:method` to communicate down the containment hierarchy. For example, a parent component calls an `aura:method` on a child component that it contains.

To communicate up the containment hierarchy, fire a component event in the child component and handle it in the parent component.

## Syntax

Use this syntax to call a method in JavaScript code.

```javascript
cmp.sampleMethod(arg1, … argN);
```

`cmp` is a reference to the component.

`sampleMethod` is the name of the `aura:method`.

`arg1, … argN` is an optional comma-separated list of arguments passed to the method. Each argument corresponds to an `aura:attribute` defined in the `aura:method` markup.

## Using Inherited Methods

A sub component that extends a super component has access to any methods defined in the super component.

An interface can also include an `<aura:method>` tag. A component that implements the interface can access the method.

## Example

Let's look at an example app.

```nolang
<!-- c:auraMethodCallerWrapper.app -->
<aura:application >
    <c:auraMethodCaller />
</aura:application>
```

`c:auraMethodCallerWrapper.app` contains a `c:auraMethodCaller` component.

```nolang
<!-- c:auraMethodCaller.cmp -->
<aura:component >
    <p>Parent component calls aura:method in child component</p>
    <c:auraMethod aura:id="child" />
    
    ...
</aura:component>
```

`c:auraMethodCaller` is the parent component. `c:auraMethodCaller` contains the child component, `c:auraMethod`.

We'll show how `c:auraMethodCaller` calls an `aura:method` defined in `c:auraMethod`.

We'll use `c:auraMethodCallerWrapper.app` to see how to return results from synchronous and asynchronous code.

-   **[Return Result for Synchronous Code](https://developer.salesforce.com/docs/platform/aura-platform/guide/js-cmp-methods-sync.md)**  


    `aura:method` executes synchronously. A synchronous method finishes executing before it returns. Use the `return` statement to return a value from synchronous JavaScript code.

-   **[Return Result for Asynchronous Code](https://developer.salesforce.com/docs/platform/aura-platform/guide/js-cmp-methods-async.md)**  


    `aura:method` executes synchronously. Use the `return` statement to return a value from synchronous JavaScript code. JavaScript code that calls a server-side action is asynchronous. Asynchronous code can continue to execute after it returns. You can’t use the `return` statement to return the result of an asynchronous call because the `aura:method` returns before the asynchronous code completes. For asynchronous code, use a callback instead of a `return` statement.


**See Also**  


-   [aura:method](https://developer.salesforce.com/docs/platform/aura-platform/ref/ref-tag-method.md)
-   [Component Events](https://developer.salesforce.com/docs/platform/aura-platform/events/events-component.md)

