Written by

Fuma Nama

At

Fri Mar 28 2025

Fumadocs v15.2

从只用 Next.js 到先用 Next.js。

Back

概览

🌐 Overview

Fumadocs 15.2 在 fumadocs-core 之上引入了一层,以扩展对其他 React 框架的支持,包括 React Router 和 Tanstack Start。其他框架也可以使用来自 fumadocs-core/framework/baseFrameworkProvider 进行支持。

🌐 Fumadocs 15.2 introduces a layer over fumadocs-core to extend support to other React frameworks, including React Router and Tanstack Start. Other frameworks can also be supported using the FrameworkProvider from fumadocs-core/framework/base.

为什么?

🌐 Why?

Fumadocs 的主要关注点是灵活性,我的目标是支持更多的框架,只要不改变 Fumadocs 的基本原则,例如核心包和 UI 包的分离。

🌐 The main focus of Fumadocs is flexibility, I aim to support more frameworks as long as it doesn't change the fundamentals of Fumadocs, like the separation of core and UI package.

React.js 生态系统的工作非常愉快,将 Fumadocs 移植到其他框架并不像我想象的那么困难。我的目标也不仅是让它适用于 Next.js 开发者,还要让整个生态系统中使用 SSR 兼容 React 框架的所有人都能使用它。

🌐 The React.js ecosystem is a joy to work with, porting Fumadocs to other frameworks isn't as difficult as I thought. It's also my goal to make it work not only for Next.js devs, but also everyone in the ecosystem who is using a SSR-compatible React framework.

重大更改

🌐 Breaking Changes

这是一个小版本更新,除非你在没有 fumadocs-ui 的情况下依赖 fumadocs-core 的低层 API,否则它不应破坏任何之前的用法。

🌐 This is a minor release, it shouldn't break any previous usages unless you're relying on the lower level APIs from fumadocs-core without fumadocs-ui.

Fumadocs 核心现在需要一个 FrameworkProvider。只需用合适的提供者将其封装即可:

🌐 Fumadocs Core now requires a FrameworkProvider. It's as simple as wrapping it with appropriate provider:

import { NextProvider } from 'fumadocs-core/framework/next';

export function Provider({ children }) {
  return <NextProvider>{children}</NextProvider>;
}

如果你正在使用 Fumadocs 界面,则无需更改。RootProvider 默认包含它,并允许你提供自己的框架,方式如下:

🌐 If you're using Fumadocs UI, there's no need to change. RootProvider included it by default, and allows you to provide your own framework with:

import { RootProvider } from 'fumadocs-ui/provider/base';

export function Provider({ children }) {
  // now it doesn't add the Next.js provider
  return <RootProvider>{children}</RootProvider>;
}

如果你发现任何公共 API 异常失效,请报告问题。

🌐 Please report issues if you find any public APIs are broken unexpectedly.

编译时间

🌐 Compilation Time

15.2 还对 Fumadocs 进行了一些小的性能改进,Turbopack 启动开发服务器并编译其第一页文档所需的时间约为 2-3 秒。

这一变化还可能使 Fumadocs 能在 Vite 上运行,最小 React Router 配置的生产构建在 Macbook 上只需大约 4 秒。

🌐 This change also potentially allows Fumadocs to run on Vite, production build of minimal React Router setup only takes around 4s on a Macbook.

试试

🌐 Try it out

从现有的 Next.js 文档升级:

🌐 Upgrade from your existing Next.js docs:

pnpm update -i -r

如果你想尝试 React Router 示例:

🌐 If you want to try the React Router example:

pnpm create fumadocs-app

未来计划

🌐 Future Plans

15.2 不支持 Astro,除非 Astro 提供更好的 React.js 支持,否则可能也不会支持。

  • transition:persist 是 Fumadocs 用户界面布局所必需的,但这也会影响其子元素(例如 MDX 内容),导致页面内容在导航后仍被保留。
  • React 上下文无法跨岛工作,这会显著改变 Fumadocs 的使用方式,因此需要重新设计 API。

Fumadocs 将继续以 Next.js 为优先,文档不会更改以泛化其他框架的使用。相反,将会开发一个针对其他框架的新文档网站(计划中)。

🌐 Fumadocs will continue to be Next.js first, the docs won't be changed to generalize usages of other frameworks. Instead, a new docs site will be developed for other frameworks (planned).