Custom Search
For other search solutions.
Overview
You can integrate any search engine with Fumadocs.
Search Indexes
Fumadocs MDX exposes the search indexes of your pages at runtime.
To export them statically, add a pre-rendered static.json route, and process its records with a script after each build:
import { createFileRoute } from '@tanstack/react-router';
import { source } from '@/lib/source';
async function getDocuments() {
const documents = [];
for (const page of source.getPages()) {
documents.push({
structured: await page.data.structuredData(),
url: page.url,
title: page.data.title,
description: page.data.description,
});
}
return documents;
}
export const Route = createFileRoute('/static.json')({
server: {
handlers: {
GET: async () => Response.json(await getDocuments()),
},
},
});
The structured field holds the headings and paragraphs of each page. Use it to generate accurate search indexes.
How is this guide?
Last updated on
