# Check Availability

Before allowing users to claim a subname, you'll want to check if it's already taken. The `useIsSubnameAvailable` hook queries JustaName's registry to determine availability in real-time.

#### How It Works

The hook accepts a `username` parameter (the subname without the parent domain) and returns:

* `isSubnameAvailable`: Boolean indicating if the name is free to claim
* `isLoading`: Boolean for loading state during the check

#### Best Practice: Debouncing

Since users type character-by-character, you should debounce the input to avoid excessive API calls. This improves performance and reduces unnecessary network requests.

```tsx
import { useIsSubnameAvailable } from '@justaname.id/react';
import { useState } from 'react';
import { useDebounce } from '@uidotdev/usehooks';

export const CheckAvailability = () => {
  const [username, setUsername] = useState('');
  
  // Wait 500ms after user stops typing before checking
  const debouncedUsername = useDebounce(username, 500);
  
  const { isSubnameAvailable, isLoading } = useIsSubnameAvailable({
    username: debouncedUsername
  });

  return (
    <div>
      <input
        value={username}
        onChange={(e) => setUsername(e.target.value)}
        placeholder="Enter username"
      />
      {isLoading && <span>Checking...</span>}
      {!isLoading && debouncedUsername && (
        <span>{isSubnameAvailable ? '✅ Available' : '❌ Taken'}</span>
      )}
    </div>
  );
};
```


---

# 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/react-sdk/check-availability.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.
