> For AI agents: the complete documentation index is available at https://rspress.rs/zh/llms.txt, the full documentation bundle is available at https://rspress.rs/zh/llms-full.txt.

# ~~usePageData~~

`usePageData` 公开当前页面的元数据，方便在自定义组件或工具函数中直接读取。

- **类型：** `() => PageData`

返回的 `PageData` 对象包含页面标题、路由路径、Frontmatter 以及站点级数据，在服务端和客户端均可使用，适合 SSR 与 SSG 场景。

> 相关功能已拆分为 [`usePage`](https://rspress.rs/zh/ui/hooks/use-page.md)、[`usePages`](https://rspress.rs/zh/ui/hooks/use-pages.md) 与 [`useSite`](https://rspress.rs/zh/ui/hooks/use-site.md)，推荐按需使用对应的组合。

```tsx
import { usePageData } from '@rspress/core/runtime';

export default function PageTitle() {
  const { page } = usePageData();
  return <h1>{page.title}</h1>;
}
```

> 你可以结合 [`useLang`](https://rspress.rs/zh/ui/hooks/use-lang.md) 或 [`useVersion`](https://rspress.rs/zh/ui/hooks/use-version.md) 一起使用，根据语言或文档版本定制内容。
