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, and this page is available as Markdown at https://rspress.rs/zh/ui/hooks/use-version.md.
close

useVersion

useVersion 在开启多版本文档时提供当前文档版本。

  • 类型: () => string

可用它在 UI 中展示当前版本,或为不同版本执行分支逻辑。

import { useVersion } from '@rspress/core/runtime';

export default function VersionTag() {
  const version = useVersion();
  return <div>当前查看的文档版本:{version}</div>;
}