# Fumadocs (Framework Mode, TanStack Start): カスタム検索
URL: /ja/docs/tanstack-start/search/custom
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/[framework]/search/custom.ja.mdx

その他の検索ソリューションを利用する場合の設定です。

## 概要 [#overview]

Fumadocs には、任意の検索エンジンを統合できます。

### 検索インデックス [#search-indexes]

Fumadocs MDX は、ページの検索インデックスをランタイムに公開します。

これらを静的にエクスポートするには、事前レンダリングされる `static.json` ルートを追加し、ビルドのたびにスクリプトでそのレコードを処理してください。

```ts tab="src/routes/static[.]json.ts"
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()),
    },
  },
});

```

```ts tab="vite.config.ts"
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
import { nitro } from 'nitro/vite';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [
    tanstackStart({
      prerender: {
        enabled: true,
      },
      pages: [ // [!code ++:3]
        { path: '/static.json' }
      ],
    }),
    nitro({
      preset: 'vercel',
    }),
  ],
});

```

```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;
}

const records = JSON.parse(await fs.readFile('.vercel/output/static/static.json', 'utf-8')) as DocumentRecord[];

// sync the records to your search engine

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

```

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

`structured` フィールドには、各ページの見出しと段落が格納されています。これを使って、精度の高い検索インデックスを生成してください。