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

# useStytchSession

> Access the current session state using the Stytch React SDK

To get the active Session for the currently signed in User, use the `useStytchSession` hook.

If no User is signed in, the returned value will be `null`.

If this hook may be rendered in a server environment, use the `isInitialized` property to determine if the SDK has completed initialization before using Session data.

In non-React environments, use the [`session.getSync`](https://stytch.com/docs/api-reference/consumer/frontend-sdks/vanilla-js/methods/sessions/get-session-sync) method to get the Session.

## Return Value

**session** `object | null`

The current Session.

**properties**

**session\_id** `string`

A unique identifier for a specific Session.

**user\_id** `string`

The unique ID of the affected User.

**authentication\_factors** `array[objects]`

An array of different authentication factors that comprise a Session.

**started\_at** `string`

The timestamp when the Session was created. Values conform to the RFC 3339 standard and are expressed in UTC, e.g. 2021-12-29T12:33:09Z.

**last\_accessed\_at** `string`

The timestamp when the Session was last accessed. Values conform to the RFC 3339 standard and are expressed in UTC, e.g. 2021-12-29T12:33:09Z.

**expires\_at** `string`

The timestamp when the Session expires. Values conform to the RFC 3339 standard and are expressed in UTC, e.g. 2021-12-29T12:33:09Z.

**attributes** `object`

Provided attributes help with fraud detection.

**properties**

**ip\_address** `string`

The IP address of the user.

**user\_agent** `string`

The user agent of the User.

**custom\_claims** `map`

The custom claims map for a Session. Claims can be added to a session during a Sessions authenticate call.

**roles** `array[string]`

A list of the roles associated with the session.

**isInitialized** `boolean`

Whether the SDK has completed initialization.

**fromCache** `boolean`

Whether the Session data is from persistent storage.

```jsx React theme={null}
import { useStytchSession } from '@stytch/react';

export const SessionInfo = () => {
  const { session } = useStytchSession();

  return session ? <p>Session ID: {session.session_id}</p> : <p>No active session</p>;
};
```

```json Logged in theme={null}
{
  "session": { ... },
  "isInitialized": true,
  "fromCache": false
}
```

```json Not initialized theme={null}
{
  "session": null,
  "isInitialized": false,
  "fromCache": false
}
```

```json Logged out theme={null}
{
  "session": null,
  "isInitialized": true,
  "fromCache": false
}
```
