Skip to content

useName

The useName hook is used to get name from an onchain identity provider for a given address.

Usage

Get ENS name from an address:

code
import { useName } from '@coinbase/onchainkit/identity';
 
const address = '0x02feeb0AdE57b6adEEdE5A4EEea6Cf8c21BeB6B1';
const { data: name, isLoading } = await useName({ address });

Get Basename from an address:

code
import { useName } from '@coinbase/onchainkit/identity';
import { base } from 'viem/chains';
 
const address = '0x02feeb0AdE57b6adEEdE5A4EEea6Cf8c21BeB6B1';
const { data: name, isLoading } = await useName({ address, chain: base });

Returns

useQuery<Promise<GetAddressReturnType>>

Parameters

UseNameOptions UseQueryOptions