Fumadocs

Generate Search Indexes

Integrate with search solutions seamlessly

Usage

Add buildSearchIndex to options.

import createMDX from 'fumadocs-mdx/config';
 
/** @type {import('next').NextConfig} */
const config = {
  reactStrictMode: true,
};
 
const withMDX = createMDX({
  buildSearchIndex: {},
});
 
export default withMDX(config);

After running next build, generated search indexes will be written to .next/server/chunks/fumadocs_search.json. You can access them after build.

update-index.mts
import { readFileSync } from 'node:fs';
import type { SearchIndex } from 'fumadocs-mdx';
 
const indexes = JSON.parse(
  readFileSync('./.next/server/chunks/fumadocs_search.json').toString(),
) as SearchIndex[];

Options

To customise search index generation:

import createMDX from 'fumadocs-mdx/config';
 
const withMDX = createMDX({
  buildSearchIndex: {
    // options
  },
});
PropTypeDefault
filter
(path: string) => boolean
-
productionOnly
boolean
true
getUrl
(path: string) => string
-

Last updated on

On this page

Edit on Github