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';
    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

Pass your search dialog to <RootProvider /> in the root route:

src/routes/__root.tsx
import { createRootRoute, HeadContent, Outlet, Scripts } from '@tanstack/react-router';
import { RootProvider } from 'fumadocs-ui/provider/tanstack';
import SearchDialog from '@/components/search';

export const Route = createRootRoute({
  component: RootComponent,
});

function RootComponent() {
  return (
    <html suppressHydrationWarning>
      <head>
        <HeadContent />
      </head>
      <body className="flex flex-col min-h-screen">
        <RootProvider search={{ SearchDialog }}>
          <Outlet />
        </RootProvider>
        <Scripts />
      </body>
    </html>
  );
}

How is this guide?

Last updated on