---
schema_version: "1"
id: b85fbe8ea4b1d65ea84a1fe18b22e27f0baf93a71740015a8b909659e344d777
title: Handling Component Events
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/aura-platform/guides/aura/events/events-component-handling-intro.md
canonical_url: https://developer.salesforce.com/docs/platform/aura-platform/guide/events-component-handling-intro.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: b6141b7212d434cb7ce733b1bb61c897281651feacb0430f891384647363fc70
products:
  - Lightning Aura Components Developer Guide
  - Platform Developer Content
---

# Handling Component Events

A component event can be handled by the component that fired the event or by a component in the containment hierarchy that receives the event.

Use `<aura:handler>` in the markup of the handler component. For example:

```nolang
<aura:handler name="sampleComponentEvent" event="c:compEvent"
    action="{!c.handleComponentEvent}"/>
```

The `name` attribute in `<aura:handler>` must match the `name` attribute in the `<aura:registerEvent>` tag in the component that fires the event.

The `action` attribute of `<aura:handler>` sets the client-side controller action to handle the event.

The `event` attribute specifies the event being handled. The format is `namespace:eventName`.

In this example, when the event is fired, the `handleComponentEvent` client-side controller action is called.

## Event Handling Phases

Component event handlers are associated with the bubble phase by default. To add a handler for the capture phase instead, use the `phase` attribute.

```nolang
<aura:handler name="sampleComponentEvent" event="ns:eventName"
    action="{!c.handleComponentEvent}" phase="capture" />
```

## Get the Source of an Event

In the client-side controller action for an `<aura:handler>` tag, use `evt.getSource()` to find out which component fired the event, where `evt` is a reference to the event. To retrieve the source element, use `evt.getSource().getElement()`.

-   **[Component Handling Its Own Event](https://developer.salesforce.com/docs/platform/aura-platform/guide/events-component-handling-itself.md)**  


    A component can handle its own event by using the `<aura:handler>` tag in its markup.

-   **[Handle Component Event of Instantiated Component](https://developer.salesforce.com/docs/platform/aura-platform/guide/events-component-handling-child.md)**  


    A parent component can set a handler action when it instantiates a child component in its markup.

-   **[Handling Bubbled or Captured Component Events](https://developer.salesforce.com/docs/platform/aura-platform/guide/events-component-bubbling.md)**  


    Event propagation rules determine which components in the containment hierarchy can handle events by default in the bubble or capture phases. Learn about the rules and how to handle events in the bubble or capture phases.

-   **[Handling Component Events Dynamically](https://developer.salesforce.com/docs/platform/aura-platform/guide/events-component-handling-dynamic.md)**  


    A component can have its handler bound dynamically via JavaScript. This is useful if a component is created in JavaScript on the client-side.


**See Also**  


-   [Component Event Propagation](https://developer.salesforce.com/docs/platform/aura-platform/guide/events-component-propagation.md)
-   [Handling Application Events](https://developer.salesforce.com/docs/platform/aura-platform/guide/events-application-handling.md)

