> ## Documentation Index
> Fetch the complete documentation index at: https://replyke-feat-push-rich-payload-fields.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Check Username Availability

# `useCheckUsernameAvailability`

## Overview

The `useCheckUsernameAvailability` hook is used to check if a specified username is available for use. This is helpful during user registration or profile updates to ensure the uniqueness of usernames.

## Usage Example

```tsx theme={null}
import { useCheckUsernameAvailability } from "@replyke/react-js";

function UsernameCheck({ username }: { username: string }) {
  const checkUsernameAvailability = useCheckUsernameAvailability();

  const handleCheckAvailability = async () => {
    try {
      const {available} = await checkUsernameAvailability({ username });
      console.log(
        available ? "Username is available." : "Username is already taken."
      );
    } catch (error) {
      console.error("Failed to check username availability:", error.message);
    }
  };

  return <button onClick={handleCheckAvailability}>Check Availability</button>;
}
```

## Parameters & Returns

### Parameters

The hook returns a function that accepts an object with the following field:

<ParamField path="username" type="string" required>
  The username to check for availability.
</ParamField>

### Returns

The function resolves with a boolean value:

<ResponseField name="response.available" type="boolean">
  `true` if the username is available, otherwise `false`.
</ResponseField>
