# Fumadocs (Framework Mode, Next.js): Custom Search
URL: /docs/next/search/custom
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/[framework]/search/custom.mdx

For other search solutions.

## Overview [#overview]

You can integrate any search engine with Fumadocs.

### Search Indexes [#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:

```ts tab="app/static.json/route.ts"
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 revalidate = false;

export async function GET() {
  return Response.json(await getDocuments());
}

```

```ts tab="scripts/sync-content.ts"
import * as fs from 'node:fs/promises';
import type { StructuredData } from 'fumadocs-core/mdx-plugins';

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

// Next.js writes it under `route-cache` when built with an adapter, like on Vercel
const [file] = await Array.fromAsync(fs.glob('.next/server/{app,route-cache/*/*/$}/static.json.body'));
const records = JSON.parse(await fs.readFile(file, 'utf-8')) as DocumentRecord[];

// sync the records to your search engine

console.log(`search updated: ${records.length} records`);

```

```json tab="package.json"
{
  "scripts": {
    "build": "next build && node --env-file-if-exists=.env.local scripts/sync-content.ts"
  }
}
```

The `structured` field holds the headings and paragraphs of each page. Use it to generate accurate search indexes.