---
schema_version: "1"
id: be19c7433c784df373ec1e828c8170e6ab6025503cb4bbe153ec2144a48f2667
title: Finding Components by ID
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/aura-platform/guides/aura/js-cb/js-cb-find-by-id.md
canonical_url: https://developer.salesforce.com/docs/platform/aura-platform/guide/js-cb-find-by-id.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: faa87fc1f1f0a9809419f3647cbe77d619c58a0a2143ff7793c122a8c9160a30
products:
  - Lightning Aura Components Developer Guide
  - Platform Developer Content
---

# Finding Components by ID

Retrieve a component by its ID in JavaScript code.

Use `aura:id` to add a local ID of `button1` to the `lightning:button` component.

<!-- otherprops: set_clipboard -->
```nolang
<lightning:button aura:id="button1" label="button1"/>

```

You can find the component by calling `cmp.find("button1")`, where `cmp` is a reference to the component containing the button. The `find()` function has one parameter, which is the local ID of a component within the markup.

`find()` returns different types depending on the result.

-   If the local ID is unique, `find()` returns the component.
-   If there are multiple components with the same local ID, `find()` returns an array of the components.
-   If there is no matching local ID, `find()` returns `undefined`.

**See Also**  


-   [Component IDs](https://developer.salesforce.com/docs/platform/aura-platform/components/components-ids.md)
-   [Value Providers](https://developer.salesforce.com/docs/platform/aura-platform/expr/expr-source.md)

