# useResolverMetadata

React hook that returns the latest indexed ENSIP-16 metadata publication for a resolver.

## Import

```tsx
import { useResolverMetadata } from "@ensforge/react";
```

## Usage

:::code-group
```tsx [component.tsx]
import { useResolverMetadata } from "@ensforge/react";

function Component() {
  const result = useResolverMetadata({ resolver: "0x0000000000000000000000000000000000000000" });

  return <pre>{JSON.stringify(result.data, null, 2)}</pre>;
}
```

```tsx [provider.tsx]
// [!include ~/snippets/react/provider.tsx]
```
:::

## Parameters

```ts
import type { UseEnsAtomParameters } from "@ensforge/react";
import type { GetResolverMetadataParametersType } from "@ensforge/sdk/indexer";
```

### resolver

`` `0x${string}` ``

Resolver contract whose latest metadata publication should be returned.

### enabled

`boolean | undefined`

Defaults to `true`. Set it to `false` to keep the atom idle without executing the action.

### map

`(value: Success) => Mapped | undefined`

Maps successful data for this hook without changing the value stored by the underlying atom.

### atom

`EnsAtomOptions<Failure> | undefined`

Controls the Effect Atom lifecycle for this hook.

| Property          | Type                         | Default       | Description                                     |
| ----------------- | ---------------------------- | ------------- | ----------------------------------------------- |
| `idleTTL`         | `Duration.Input`             | `"5 minutes"` | Retains an unused atom before it is disposed.   |
| `refreshInterval` | `false \| Duration.Input`    | `false`       | Refreshes the atom while it remains subscribed. |
| `retry`           | `false \| Schedule`          | `false`       | Retries typed failures with an Effect schedule. |
| `swr`             | `false \| EnsAtomSwrOptions` | enabled       | Configures stale-while-revalidate behavior.     |

See [Atom Options](/react/api/atom-options) for focused examples.

## Return Type

```ts
type Result = ReturnType<typeof useResolverMetadata>;
```

Successful `data` has type `GetResolverMetadataResultType`.

This operation depends on the ENSv2 indexer and returns a discriminated union:

* `{ status: "supported", value }` when a V2 indexer is configured and available.
* `{ status: "unsupported", network, reason }` when V2 discovery is disabled or unavailable.

Check `status` before reading `value`. An unavailable V2 source is represented as data rather than
an exception so applications can keep supporting networks that only expose ENSv1 indexing.

Returns an [`EnsAtomResult`](/react/api/atom-result).

| Property        | Description                                             |
| --------------- | ------------------------------------------------------- |
| `data`          | Successful action data, or `undefined` before success.  |
| `error`         | Typed action failure, an unexpected `Error`, or `null`. |
| `cause`         | Complete Effect cause for the latest failure.           |
| `isInitial`     | No execution has completed yet.                         |
| `isWaiting`     | Initial or background work is running.                  |
| `isSuccess`     | The atom contains a successful value.                   |
| `isFailure`     | The atom contains a failed result.                      |
| `refresh`       | Refreshes the atom and returns a Promise.               |
| `refreshEffect` | Refreshes with a typed Effect error channel.            |
| `result`        | Underlying Effect `AsyncResult`.                        |
| `updatedAt`     | Timestamp of the latest successful value.               |

## Suspense

Use `useResolverMetadataSuspense` beneath React [Suspense](https://react.dev/reference/react/Suspense) and an error boundary. It starts immediately, suspends during the initial load, and throws typed failures to the nearest error boundary.

### Import

```tsx
import { useResolverMetadataSuspense } from "@ensforge/react";
```

### Usage

```tsx
const result = useResolverMetadataSuspense({
  resolver: "0x0000000000000000000000000000000000000000",
});
```

### Parameters

`useResolverMetadataSuspense` accepts the same operation parameters described above. Its Effect Atom options omit `enabled` because a Suspense read always executes.

### map

`(value: Success) => Mapped | undefined`

Maps successful data for this hook without changing the value stored by the underlying atom.

### atom

`EnsAtomOptions<Failure> | undefined`

Controls retries, refreshes, disposal, and stale-while-revalidate behavior. Suspense hooks always
execute and do not accept `enabled`.

| Property          | Type                         | Default       | Description                                     |
| ----------------- | ---------------------------- | ------------- | ----------------------------------------------- |
| `idleTTL`         | `Duration.Input`             | `"5 minutes"` | Retains an unused atom before it is disposed.   |
| `refreshInterval` | `false \| Duration.Input`    | `false`       | Refreshes the atom while it remains subscribed. |
| `retry`           | `false \| Schedule`          | `false`       | Retries typed failures with an Effect schedule. |
| `swr`             | `false \| EnsAtomSwrOptions` | enabled       | Configures stale-while-revalidate behavior.     |

See [Atom Options](/react/api/atom-options) for focused examples.

### Return Type

```ts
type Result = ReturnType<typeof useResolverMetadataSuspense>;
```

Returns `EnsSuspenseAtomResult` with successful `data`, background `isWaiting` state, and
`updatedAt`. Pending work suspends rendering and failures are thrown to the nearest error boundary.

## Effect Atom

```ts
import { getResolverMetadataAtom } from "@ensforge/react/atoms";
import { sdk } from "./client";

const atom = getResolverMetadataAtom(sdk, parameters, options);
```

The hook creates this atom with the SDK and registry supplied by [`EnsforgeProvider`](/react/api/ensforge-provider).

## Actions

* [`getResolverMetadata`](/core/api/actions/indexer/resolvers/get-resolver-metadata)
* [`sdk.indexer.getResolverMetadata`](/sdk/api/indexer/resolvers/get-resolver-metadata)
