> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crossmint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# User Profile

> Retrieve user profile data such as email or social login metadata

<Snippet file="auth-staging-note.mdx" />

Crossmint Auth provides a way to retrieve and update user profile data, such as email, social login metadata, and more.

<AccordionGroup>
  <Accordion title="Fields in the User Object">
    The user object contains the following information:

    * `id`: User's unique identifier.
    * `email`: User's email address.
    * `phoneNumber`: User's phone number.
    * `farcaster`: User's Farcaster account data.
    * `twitter`: User's Twitter (X) account data.

    Farcaster Account data contains:

    * `fid`: User's Farcaster ID.
    * `username`: User's Farcaster username.
    * `bio`: User's Farcaster bio.
    * `displayName`: User's Farcaster display name.
    * `pfpUrl`: User's Farcaster profile image URL.
    * `custody`: User's FID custody address.
    * `verifications`: List of the user's verified addresses.

    Twitter Account data contains:

    * `id`: User's Twitter ID.
    * `username`: User's Twitter username.
  </Accordion>
</AccordionGroup>

## Reading User Data

This API requires the `users.read` scope.

* **Server side**: Requires a server-side API key.
* **Client side**: Requires a client-side API key, and a logged in user.

### Server-side

For server-side operations, use the `@crossmint/server-sdk` that provides a `getUser` function to fetch user information.

```typescript theme={null}
import { createCrossmint, CrossmintAuth } from "@crossmint/server-sdk";

const crossmint = createCrossmint({ apiKey: "<YOUR_SERVER_API_KEY>" });
const crossmintAuth = CrossmintAuth.from(crossmint);

async function getUser(userId: string) {
    try {
        const user = await crossmintAuth.getUser(userId);
        console.log("User data:", user);
    } catch (error) {
        console.error("Error fetching user data:", error);
    }
}
```

### Response Format

```json theme={null}
{
    "id": "123",
    "email": "test@test.com", // Optional (if user was created with email)
    "phoneNumber": "123456789", // Optional (if user was created with phone number)
    "farcaster": {
        "fid": "123",
        "username": "johndoe",
        "bio": "Hello, I'm John Doe",
        "displayName": "John Doe",
        "pfpUrl": "https://example.com/pfp.jpg",
        "custody": "0x1234567890123456789012345678901234567890",
        "verifications": ["0x1234567890123456789012345678901234567890"]
    },
    "twitter": {
        "id": "456",
        "username": "johndoe"
    }
}
```

### Client-side

Use the `useAuth` react hook from `@crossmint/client-sdk-react-ui` to access the user object.

<Note>
  If you would like to use a different framework, [contact support](https://help.crossmint.com/hc/en-us/requests/new)
</Note>

```tsx React theme={null}
import { useAuth } from "@crossmint/client-sdk-react-ui";

function User() {
    const { user } = useAuth();

    if (!user) {
        return <div>Loading user...</div>;
    }

    return (
        <div>
            <h1>User</h1>
            <p>User ID: {user.id}</p>
            <p>Email: {user.email}</p>
            <p>Phone Number: {user.phoneNumber}</p>
            <p>Farcaster FID: {user.farcaster?.fid}</p>
            <p>Farcaster Username: {user.farcaster?.username}</p>
            <p>Farcaster Bio: {user.farcaster?.bio}</p>
            <p>Farcaster Display Name: {user.farcaster?.displayName}</p>
            <p>Farcaster PFP URL: {user.farcaster?.pfpUrl}</p>
            <p>Farcaster Custody: {user.farcaster?.custody}</p>
            <p>Farcaster Verifications: {user.farcaster?.verifications}</p>
            <p>Twitter ID: {user.twitter?.id}</p>
            <p>Twitter Username: {user.twitter?.username}</p>
        </div>
    );
}
```
