Overview
- React Query hook that fetches the Initia (
.init) username for a provided address, or for the connected address when no argument is passed. - Automatically re-runs when the target address changes.
- Exposes standard React Query state (
isLoading,error, etc.).
Prerequisites
- Must be rendered within
InterwovenKitProvider. - Must be used within a React Query
QueryClientProvider. - Must be used within a wagmi
WagmiProvider. - Client-only (no SSR): Put this in a
use clientprovider tree, or use a dynamic import in Next.js.
Quickstart
Connected Wallet
CalluseUsernameQuery() with no arguments to resolve the username for the
currently connected wallet.
Specific Address
Pass an address to resolve the username for that address instead of the connected wallet.These examples assume providers are already set up. For complete setup
configurations, see Provider Setup.
Return value
UseQueryResult<string | null> object. The data
property is:
stringwhen a username exists (ends with.init)nullwhen no username exists or the address is invalidundefinedbefore the query has produced a value or when the query is disabled (for example, when neither an explicit address nor a connected wallet address is available)
UseQueryResult is from @tanstack/react-query.
Notes
- If
addressis omitted, the hook falls back to the connected address fromuseAddress().