# useAddressEnsNames

A React hook for fetching ENS names and their records associated with a specific Ethereum address.

***

## Usage

```typescript
import { useAddressEnsNames } from '@justaname.id/react'

// Basic usage
function AddressEnsNamesComponent() {
  const { 
    addressEnsNames, 
    isAddressEnsNamesPending, 
    refetchAddressEnsNames 
  } = useAddressEnsNames({
    address: '0x1234567890abcdef1234567890abcdef12345678'
  })
  
  if (isAddressEnsNamesPending) return <div>Loading ENS names...</div>
  
  return (
    <div>
      <h3>ENS Names for Address</h3>
      {addressEnsNames?.map((record, index) => (
        <div key={index}>
          <strong>{record.ens}</strong>
          <p>Avatar: {record.sanitizedRecords?.avatar}</p>
          <p>Description: {record.sanitizedRecords?.description}</p>
        </div>
      ))}
      <button onClick={() => refetchAddressEnsNames()}>Refresh</button>
    </div>
  )
}
```

***

## Returns

[`UseAddressEnsNamesResult`](/sdk-reference/justaname-react-sdk/interfaces/useaddressensnamesresult.md) - An object containing:

* `addressEnsNames`: Array of [`Records`](/sdk-reference/justaname-react-sdk/interfaces/records.md) objects containing ENS names and their records
* `isAddressEnsNamesPending`: Boolean indicating if the data is being fetched
* `isAddressEnsNamesFetching`: Boolean indicating if the data is being refetched
* `isAddressEnsNamesLoading`: Boolean indicating if the data is loading for the first time
* `getEnsNamesForAddress`: Function to manually fetch ENS names for an address
* `refetchAddressEnsNames`: Function to manually refetch the data

## Parameters

* **params?**: [`UseAddressEnsNamesParams`](/sdk-reference/justaname-react-sdk/interfaces/useaddressensnamesparams.md) - Optional parameters:
  * `address`: Ethereum address to fetch ENS names for
  * `chainId`: Chain ID (defaults to provider's chainId)
  * `enabled`: Whether to enable the query (defaults to true)

## Defined in

[packages/@justaname.id/react/src/lib/hooks/ens/useAddressEnsNames.ts:35](https://github.com/JustaName-id/JustaName-sdk/blob/dc845c10af242e3ca87d95ef392516ac0bfa8b95/packages/@justaname.id/react/src/lib/hooks/ens/useAddressEnsNames.ts#L35)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.justaname.id/sdk-reference/justaname-react-sdk/functions/useaddressensnames.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
