# Fumadocs (Framework Mode, Next.js): Orama Cloud
URL: /zh-TW/docs/next/search/orama-cloud
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/[framework]/search/orama-cloud.zh-TW.mdx

在 Fumadocs UI 中使用 Orama Cloud。

## 設定 [#setup]

Fumadocs CLI 可以幫您完成設定，它會建立搜尋對話方塊、`static.json` 路由，以及一個在每次建置後同步搜尋索引的指令碼：

```package-install
npx @fumadocs/cli feature search --provider orama-cloud
```

或手動設定：

1. 整合 [Orama Cloud](/docs/headless/search/orama-cloud)。

2. 建立搜尋對話方塊，並將 `endpoint` 與 `api_key` 替換為您要使用的值。

   ```tsx title="components/search.tsx"
   'use client';

   import {
     SearchDialog,
     SearchDialogClose,
     SearchDialogContent,
     SearchDialogFooter,
     SearchDialogHeader,
     SearchDialogIcon,
     SearchDialogInput,
     SearchDialogList,
     SearchDialogOverlay,
     type SharedProps,
   } from 'fumadocs-ui/components/dialog/search';
   import { useOramaCloudSearch } from 'fumadocs-core/search/client';
   import { OramaCloud } from '@orama/core';
   import { useI18n } from 'fumadocs-ui/contexts/i18n';

   const orama = new OramaCloud({
     projectId: '',
     apiKey: '',
   });

   export default function CustomSearchDialog(props: SharedProps) {
     const { locale } = useI18n(); // (optional) for i18n
     const search = useOramaCloudSearch({
       client: orama,
       locale,
     });

     return (
       <SearchDialog {...search} {...props}>
         <SearchDialogOverlay />
         <SearchDialogContent>
           <SearchDialogHeader>
             <SearchDialogIcon />
             <SearchDialogInput />
             <SearchDialogClose />
           </SearchDialogHeader>
           <SearchDialogList />
           <SearchDialogFooter>
             <a
               href="https://orama.com"
               rel="noreferrer noopener"
               className="ms-auto text-xs text-fd-muted-foreground"
             >
               Search powered by Orama
             </a>
           </SearchDialogFooter>
         </SearchDialogContent>
       </SearchDialog>
     );
   }
   ```

### 替換搜尋對話方塊 [#replace-search-dialog]

請將您的搜尋對話方塊傳入 [`<RootProvider />`](/docs/ui/layouts/root-provider)。由於根版面配置是伺服器元件，請先用用戶端元件包裝 provider：

```tsx tab="components/provider.tsx"
'use client';
import { RootProvider } from 'fumadocs-ui/provider/next';
import SearchDialog from '@/components/search';
import type { ReactNode } from 'react';

export function Provider({ children }: { children: ReactNode }) {
  return <RootProvider search={{ SearchDialog }}>{children}</RootProvider>;
}
```

```tsx tab="app/layout.tsx"
// [!code ++]
import { Provider } from '@/components/provider';
import type { ReactNode } from 'react';

export default function Layout({ children }: { children: ReactNode }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body className="flex flex-col min-h-screen">
        {/* [!code --] */}
        <RootProvider>{children}</RootProvider>
        {/* [!code ++] */}
        <Provider>{children}</Provider>
      </body>
    </html>
  );
}
```