跳到主要內容
+

useSession API

useSession hook 的 API 參考。

匯入

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

閱讀這篇關於最小化 bundle 大小的指南,以了解差異。

用法

您可以在 Toolpad 核心組件中調用 hook 來存取 SessionContext 的當前值

const session = useSession();

由 @toolpad/core 匯出的預設 Session 介面具有以下欄位

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