Advanced API
Read Git history yourself for custom layouts and content pipelines.
The compiler plugin covers most sites. Use these APIs when you need history somewhere the plugin doesn't run, such as a custom layout or a page that isn't compiled from Markdown.
Read history
Read the history in a server component or build script, then render it:
import 'server-only';
import { readPageHistory } from 'fumadocs-page-history/git';
import { GitChangelog } from 'fumadocs-page-history/ui';
export async function PageHistory({ path }: { path: string }) {
const commits = await readPageHistory(path, {
repository: { url: 'https://github.com/owner/repository' },
});
return <GitChangelog commits={commits} />;
}path is the file's path relative to the Git root, such as content/docs/guide.mdx, not a URL or slug. The options are the same as the plugin's; see Advanced Git controls. Without repository.directory, Git is found from the current working directory.
This needs Git and a full checkout wherever the code runs, and it throws if the clone is shallow or a Git command fails. If your server doesn't have Git, read the history during the build, save it as JSON, and import that file instead.
Reuse a reader
Each readPageHistory() call reads the repository's metadata again. If a build processes many files, create one reader and reuse it:
import { createHistoryReader } from 'fumadocs-page-history/git';
const history = createHistoryReader({ repository: { url: 'https://github.com/owner/repository' } });
const commits = await history.read('content/docs/guide.mdx');Create a new reader for each build so it doesn't keep outdated data. The compiler plugins already do this.
Components
GitChangelog takes commits, optional extra authors, and the display options as props. If your commit records don't include repositoryUrl, pass repository={{ url }} so that #123 issue links work.
To show only contributors:
import { GitContributors } from 'fumadocs-page-history/ui';
<GitContributors commits={commits} authors={authors} />;A few helpers match what the plugins do:
resolveAuthors(names, authorMappings)fromfumadocs-page-history/gitturns frontmatterauthorsinto author records.shouldShowChangelog(frontmatter)andshouldShowContributors(frontmatter)fromfumadocs-page-historyapply the per-page settings.
Workspace changes
The Workspace changes guide covers the normal setup. For your own integration, readPageChanges(options, sourcePath) from fumadocs-page-history/workspace returns the comparison as JSON-serializable data.
GitPageChangesView, GitChangeList, GitChangeBlock, and GitChangeText from fumadocs-page-history/ui render that data. They don't access Git or refresh anything themselves; the demo uses them with saved examples.