# `useUser`

Accesses the current authenticated user and account information. Updates automatically when the user signs in, signs out, or their profile changes.

## Usage

```tsx
import { useUser } from '@openfort/react-native';

function Profile() {
  const { user, isAuthenticated, getAccessToken } = useUser();

  // Check if user is authenticated
  if (!isAuthenticated) return <SignIn />;

  // Get access token for API calls
  const makeApiCall = async () => {
    const token = await getAccessToken();
    // Use token in API requests
  };

  return <Text>{user?.id}</Text>;
}
```

## Return type

The hook returns the following:

```ts
type UseUserReturn = {
  user: User | null        // Current user object
  isAuthenticated: boolean // Whether user is logged in
  getAccessToken(): Promise<string | null>  // Get access token
}

type User = {
  id: string               // Unique user identifier
  email?: string           // User's email address
  name?: string            // User's display name
  image?: string           // URL to user's profile image
  emailVerified?: boolean  // Whether the user's email has been verified
  createdAt?: string       // ISO timestamp when the user was created
  updatedAt?: string       // ISO timestamp when the user was last updated
  isAnonymous?: boolean    // Whether the user is anonymous (guest)
}
```

## `getAccessToken`

Retrieves the current user's access token for making authenticated API requests.

**For native Openfort auth** (email, OAuth, guest, wallet): retrieves the stored Openfort access token.

**For third-party auth** (Firebase, Supabase, etc.): calls the `thirdPartyAuth.getAccessToken` function configured in `OpenfortProvider` and exchanges that token for an Openfort session. See [Using Your Own Authentication](/docs/products/embedded-wallet/react-native/auth/third-party) for setup details.
