> ## 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 Update User

# `useUpdateUser`

## Overview

The `useUpdateUser` hook is used to update a user's profile information. This includes updating fields such as name, username, avatar, bio, and more. It also supports metadata updates for flexible user data management.

## Usage Example

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

function UpdateUserForm({ userId }: { userId: string }) {
  const updateUser = useUpdateUser();

  const handleUpdateUser = async () => {
    try {
      const updatedUser = await updateUser({
        userId,
        update: {
          name: "John Doe",
          username: "johndoe123",
          bio: "Loving life and coding!",
        },
      });

      console.log("User updated successfully:", updatedUser);
    } catch (error) {
      console.error("Failed to update user:", error.message);
    }
  };

  return <button onClick={handleUpdateUser}>Update User</button>;
}
```

## Parameters & Returns

### Parameters

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

<ParamField path="userId" type="string" required>
  The ID of the user to update.
</ParamField>

<ParamField path="update" type="UpdateUserParams" required>
  The fields and values to update for the user.
</ParamField>

#### `UpdateUserParams`

| Field            | Type                                              | Required | Description                                                               |
| ---------------- | ------------------------------------------------- | -------- | ------------------------------------------------------------------------- |
| `name`           | `string \| null`                                  | No       | The new name for the user.                                                |
| `username`       | `string \| null`                                  | No       | The new username for the user.                                            |
| `avatar`         | `string \| null`                                  | No       | The URL of the user's avatar.                                             |
| `bio`            | `string`                                          | No       | A short biography for the user.                                           |
| `birthdate`      | `Date \| null`                                    | No       | The user's birthdate.                                                     |
| `location`       | `{ latitude: number; longitude: number } \| null` | No       | The user's geographic location.                                           |
| `metadata`       | `Record<string, any>`                             | No       | Additional metadata associated with the user.                             |
| `secureMetadata` | `Record<string, any>`                             | No       | Sensitive metadata for the user, not attached to Entity and Comment data. |

### Returns

The function resolves with an object containing the updated user details:

<ResponseField name="AuthUser" type="AuthUser">
  The updated user object.
</ResponseField>
