Fumadocs rebuilt on Hamur, the original is fumadocs.dev
Skip to Content
Fumadocs

Orama Cloud

Using Orama Cloud with Fumadocs UI.

Setup

Fumadocs CLI can set it up for you, it creates the search dialog, the static.json route and a script to sync the search index after each build:

npx @fumadocs/cli feature search --provider orama-cloud

Or manually:

  1. Integrate Orama Cloud.

  2. Create a search dialog, replace endpoint and api_key with your desired values.

    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';
    
    const orama = new OramaCloud({
      projectId: '',
      apiKey: '',
    });
    
    export default function CustomSearchDialog(props: SharedProps) {
      const search = useOramaCloudSearch({
        client: orama,
      });
    
      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

Your provider component already passes src/components/search.tsx to <RootProvider />, so replacing that file is enough:

src/components/provider.tsx
import { navigate } from 'astro:transitions/client';
import type { ReactNode } from 'react';
import { RootProvider } from 'fumadocs-ui/provider/astro';
import SearchDialog from '@/components/search';

export interface ProviderProps {
  pathname: string;
  params: Record<string, string | undefined>;
  children?: ReactNode;
}

export function Provider({ pathname, params, children }: ProviderProps) {
  return (
    <RootProvider
      pathname={pathname}
      params={params}
      navigate={navigate}
      search={{ SearchDialog }}
    >
      {children}
    </RootProvider>
  );
}

How is this guide?

Last updated on