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

# useSession()

## Overview

**useSession** hook is used to access the current session and user details from the SessionContext.

## Example Usage

```typescript session-component.tsx
import { useSession } from '@locai1/iam-react';

const SIGN_IN_PAGE = "/sign-in";

const Header = () => {
  const { isSignedIn } = useSession();

  return (
    <header>
      {isSignedIn && (
        <button>
          Sign Out
        </button>
      )}
      {!isSignedIn && (
        <Link href={SIGN_IN_PAGE}>
          Sign In
        </Link>
      )}
    </header>
  );
};
```

## Returns

<ResponseField name="isSignedIn" type="boolean">
  boolean indicating whether the user is signed in.
</ResponseField>

<ResponseField name="session" type="Session | undefined">
  current session object.

  ```typescript Session type
  type Session = {
    sessionId: string;
    sessionToken: string;
    userId: string;
  };
  ```
</ResponseField>

<ResponseField name="userDetails" type="UserDetails | undefined">
  details of the currently signed-in user.

  ```typescript UserDetails type
  type UserDetails = {
    firstName: string;
    lastName: string;
    phoneNumber: string;
    email: string;
    isEmailVerified: boolean;
    isPhoneVerified: boolean;
    userState: string;
    displayName: string;
    metadata?: Record<string, string>;
  };
  ```
</ResponseField>
