Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Get All Subnames for an Owner

Sometimes you need to fetch all subnames associated with a particular owner, for example, to display a user's complete ENS portfolio or to build admin interfaces for subname management.

For the Connected Account

Use useAccountSubnames to fetch subnames owned by the currently connected wallet:

tsx

import { useAccountSubnames } from '@justaname.id/react';

export const MySubnames = () => {
  const { accountSubnames, isLoading } = useAccountSubnames();

  if (isLoading) return <div>Loading your subnames...</div>;
  
  if (!accountSubnames?.length) {
    return <div>You don't have any subnames yet.</div>;
  }

  return (
    <div>
      <h3>My Subnames ({accountSubnames.length})</h3>
      <ul>
        {accountSubnames.map((subname) => (
          <li key={subname.ens}>
            <strong>{subname.ens}</strong>
            <span>Claimed: {new Date(subname.claimedAt).toLocaleDateString()}</span>
          </li>
        ))}
      </ul>
    </div>
  );
};

For Any Address

Use useAddressSubnames when you need to look up subnames for an arbitrary address (not necessarily the connected user):

tsx

Response Structure

The useAddressSubnames hook returns data grouped by parent domain:

typescript

Last updated