Skip to content
+

useSession API

API reference for the useSession hook.

Import

import useSession from '@toolpad/core/useSession';
// or
import { useSession } from '@toolpad/core';

Learn about the difference by reading this guide on minimizing bundle size.

Usage

You can get access to the current value of the SessionContext inside Toolpad Core components by invoking the hook:

const session = useSession();

The default Session interface exported by @toolpad/core has the following fields:

export interface Session {
  user?: {
    id?: string | null;
    name?: string | null;
    image?: string | null;
    email?: string | null;
  };
}