---
title: Custom Search
description: For other search solutions.
---

## Overview

Fumadocs is very flexible, you can integrate custom search with Fumadocs easily.

### Search Indexes

With Fumadocs MDX, the generated search indexes are exposed during runtime.

To expose search indexes statically, create a function to generate records.

```ts title="lib/export-search-indexes.ts"
import { source } from '@/lib/source';
import type { StructuredData } from 'fumadocs-core/mdx-plugins';

export interface DocumentRecord {
  title: string;
  description?: string;
  url: string;
  structured: StructuredData;
}

export async function exportSearchIndexes() {
  const results: DocumentRecord[] = [];

  for (const page of source.getPages()) {
    results.push({
      structured: page.data.structuredData,
      url: page.url,
      title: page.data.title,
      description: page.data.description,
    });
  }

  return results;
}
```

Export it via static route handler.

<include cwd>content/docs/headless/search/.static-route-example.mdx</include>

Finally, the exported records can be accessed at:

<include cwd>content/docs/headless/search/.static-route-output.mdx#static-route-output</include>

You can read it for further processing:

```ts
import * as fs from 'node:fs';
import type { DocumentRecord } from '@/lib/export-search-indexes';

const content = fs.readFileSync(filePath);
const records = JSON.parse(content.toString()) as DocumentRecord[];
```

Use `structuredData` to generate accurate search indexes.
