fumadocs-extras
v0.3.0
Published
Drop-in extras for Fumadocs: a grouped "Open in AI" page actions menu and Markdown links for llms.txt
Maintainers
Readme
fumadocs-extras
Extras for Fumadocs: a page actions menu for Fumadocs UI, and build-time helpers that link llms.txt and the Markdown for LLMs to the Markdown copies of pages and point agents to the llms.txt of every language.
Page actions
ViewOptionsPopover replaces the "Open" menu of Fumadocs page actions. The props are the same, so you only have to change the import. It adds:
- Four groups with separators between them: page source, web chats, desktop apps and coding agents.
- Perplexity, Grok, Claude Desktop, Claude Code and Codex, next to GitHub, Markdown, Scira AI, ChatGPT, Claude and Cursor.
- An
itemsprop that turns groups or single items on and off. - Prompts that ask the AI tools to read the Markdown copy (
markdownUrl) when there is one. - The repository and branch passed to Claude Code when
githubUrlpoints to GitHub. - The ChatGPT, Claude and Cursor marks on the trigger.
- Links named by their text only, with the brand icons hidden from screen readers.
- English, Simplified Chinese and Traditional Chinese labels.

Install
pnpm add fumadocs-extrasRequires fumadocs-core 16.10 or later, React 19.2 or later and Tailwind CSS v4.
Import the preset after the Fumadocs one, so Tailwind CSS generates the classes the menu uses:
@import 'tailwindcss';
@import 'fumadocs-ui/css/neutral.css';
@import 'fumadocs-ui/css/preset.css';
@import 'fumadocs-extras/css/preset.css';Usage
Pick the entry that matches the package your app imports Fumadocs UI from:
| Your app imports from | Use |
| ------------------------------------------------------------------------------------------------------ | -------------------------------------- |
| fumadocs-ui (including @fumadocs/base-ui installed under that name, as create-fumadocs-app does) | fumadocs-extras/page-actions |
| @fumadocs/base-ui | fumadocs-extras/page-actions/base-ui |
import { MarkdownCopyButton } from 'fumadocs-ui/layouts/docs/page'
import { ViewOptionsPopover } from 'fumadocs-extras/page-actions'
;<div className="flex flex-row items-center gap-2 border-b pb-6">
<MarkdownCopyButton markdownUrl={markdownUrl} />
<ViewOptionsPopover
markdownUrl={markdownUrl}
githubUrl={`https://github.com/${owner}/${repo}/blob/main/content/docs/${page.path}`}
/>
</div>Choose the items
All items are on by default. Turn off a group or an item with items. The setting of an item wins over the setting of its group:
<ViewOptionsPopover
markdownUrl={markdownUrl}
githubUrl={githubUrl}
items={{
desktop: false, // hide a whole group
agent: false,
cursor: true, // an item wins over its group
grok: false,
}}
/>| Group | Items |
| --------- | -------------------------------------------------- |
| page | github, markdown |
| chat | scira, perplexity, grok, chatgpt, claude |
| desktop | claude-desktop |
| agent | claude-code, codex, cursor |
github and markdown also need their URL props. Empty groups leave no separator behind.
Labels
locale picks the built-in labels: en (default), zh-CN or zh-TW. labels overrides single labels:
<ViewOptionsPopover locale="zh-CN" labels={{ open: '问 AI' }} />| Key | English |
| ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------- |
| open | Open |
| prompt | Read {url} in full first. I have some questions for you: |
| github | Open in GitHub |
| markdown | View as Markdown |
| scira, perplexity, grok, chatgpt, claude, claude-desktop, claude-code, codex, cursor | Open in scira.ai, Open in perplexity.ai, … |
{url} in prompt is replaced with pageUrl. All props are serializable, so a server component can pass them.
Props
| Prop | Type | Description |
| ------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| markdownUrl | string | URL of the raw Markdown/MDX content of the page. A path gets import.meta.env.BASE_URL prefixed, which Vite and Next.js with Turbopack set to the base path. |
| githubUrl | string | Source file URL on GitHub. |
| pageUrl | string | URL the prompts ask to read. Defaults to markdownUrl resolved against the current URL, or to the current URL without query and hash when markdownUrl is not set. |
| items | Partial<Record<PageActionGroup \| PageActionId, boolean>> | Groups and items to show. |
| locale | 'en' \| 'zh-CN' \| 'zh-TW' | Built-in labels. |
| labels | Partial<PageActionLabels> | Labels to override. |
| children | ReactNode | Replaces the trigger text and marks. |
Other props go to the trigger button.
Markdown links for llms.txt
fumadocs-extras/llms runs at build time and on the server. It links llms.txt and the Markdown for LLMs to the Markdown copies of pages, where Fumadocs links the page URLs. A server can answer a page URL with Markdown when the request asks for it in the Accept header; a static export serves HTML there, so an agent following the link reads HTML.
Requires fumadocs-core 16.18 or later.
llms.txt
renderMarkdownUrl() makes a renderUrl for llms(). Each entry links the URL your function returns for its page. Entries without a page, such as external links, keep their URL.
import { llms } from 'fumadocs-core/source'
import { renderMarkdownUrl } from 'fumadocs-extras/llms'
export const docsLlms = llms(source, {
renderUrl: renderMarkdownUrl(
source,
page => `https://docs.acme.dev${getPageMarkdownUrl(page).url}`,
),
renderPage: async page =>
`# ${page.data.title} (${page.url})\n\n${await page.data.getText('processed')}`,
})Language tips
renderLlmsIndex() writes llms.txt like index() of llms(), with a summary and extra Markdown blocks under the title. renderLanguageTips() makes one such block: a <tips> element in English that names the language of the index, gives the URL pattern of the other indexes and links each of them.
import { renderLanguageTips, renderLlmsIndex } from 'fumadocs-extras/llms'
const languages = { 'en': 'English', 'zh-cn': '简体中文' }
export function llmsIndex(lang: keyof typeof languages): string {
return renderLlmsIndex(source, docsLlms, {
lang,
description: 'Guides and API reference for Acme.',
sections: [
renderLanguageTips({
language: lang,
languages,
indexUrl: code => `https://docs.acme.dev/md/${code}/llms.txt`,
}),
],
})
}/md/zh-cn/llms.txt then starts with:
# Acme Docs
> Guides and API reference for Acme.
<tips>
This index lists the pages in 简体中文 (zh-cn). Each language has its own index at `https://docs.acme.dev/md/[language code]/llms.txt`:
- en: [English](https://docs.acme.dev/md/en/llms.txt)
- zh-cn: [简体中文](https://docs.acme.dev/md/zh-cn/llms.txt)
A page has the same path in every language: change the language code in its link to read the page in another language.
</tips>Set samePath: false when page paths differ between languages.
Links between pages
remarkContentLinks rewrites links to content files, such as [Setup](./setup.mdx#install), link definitions and the href of JSX elements like <Card>. The Markdown for LLMs (includeProcessedMarkdown) gets markdownUrl, the rendered page gets pageUrl, and the hash is kept. A link to a missing file throws, so the build fails.
import { remarkContentLinks } from 'fumadocs-extras/llms'
import { defineConfig } from 'fumadocs-mdx/config'
export default defineConfig({
mdxOptions: {
remarkPlugins: defaults => [
[
remarkContentLinks,
{
dir: 'content/docs',
markdownUrl: (slugs: string[]) => `https://docs.acme.dev/docs/${slugs.join('/')}.md`,
},
],
...defaults,
],
},
})| Option | Type | Description |
| ------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| dir | string | Content directory, as passed to defineDocs(). Files outside it and links that leave it are kept as authored. |
| i18n | I18nConfig | i18n config of the loader. A link takes the locale in its target's file name or folder, or else the locale of the linking page. |
| markdownUrl | (slugs: string[], locale?: string) => string | URL written into the Markdown for LLMs. |
| pageUrl | (slugs: string[], locale?: string) => string | URL written into the rendered page. Without it, the rendered page keeps the authored link, for createRelativeLink(). |
License
MIT License © Alice39s
ViewOptionsPopover is based on the page actions of Fumadocs by Fuma Nama, under the MIT License.
