# Fire Component Events

Fire a component event to communicate data to another component. 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.

## Register an Event

A component registers that it may fire an event by using `<aura:registerEvent>` in its markup. For example:

```nolang
<aura:registerEvent name="sampleComponentEvent" type="c:compEvent"/>
```

We’ll see how the value of the `name` attribute is used for firing and handling events.

## Fire an Event

To get a reference to a component event in JavaScript, use `cmp.getEvent("evtName")` where `evtName` matches the `name` attribute in `<aura:registerEvent>`.

Use `fire()` to fire the event from an instance of a component. For example, in an action function in a client-side controller:

```javascript
var compEvent = cmp.getEvent("sampleComponentEvent");
// Optional: set some data for the event (also known as event shape)
// A parameter’s name must match the name attribute
// of one of the event’s <aura:attribute> tags
// compEvent.setParams({"myParam" : myValue });
compEvent.fire();
```

**See Also**

- [Fire Application Events](/docs/platform/aura-platform/guide/events-application-fire.md)
