Orama Cloud
Using Orama Cloud with Fumadocs UI.
Setup
-
Integrate Orama Cloud.
-
Create a search dialog, replace
endpointandapi_keywith 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 { useDocsSearch } from 'fumadocs-core/search/client'; import { OramaCloud } from '@orama/core'; import { useI18n } from 'fumadocs-ui/contexts/i18n'; const client = new OramaCloud({ projectId: '', apiKey: '', }); export default function CustomSearchDialog(props: SharedProps) { const { locale } = useI18n(); // (optional) for i18n const { search, setSearch, query } = useDocsSearch({ type: 'orama-cloud', client, locale, }); return ( <SearchDialog search={search} onSearchChange={setSearch} isLoading={query.isLoading} {...props}> <SearchDialogOverlay /> <SearchDialogContent> <SearchDialogHeader> <SearchDialogIcon /> <SearchDialogInput /> <SearchDialogClose /> </SearchDialogHeader> <SearchDialogList items={query.data !== 'empty' ? query.data : null} /> <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
Replace the search dialog with yours from <RootProvider />:
import { RootProvider } from 'fumadocs-ui/provider/<framework>';
import SearchDialog from '@/components/search';
<RootProvider
search={{
SearchDialog,
}}
>
{children}
</RootProvider>;If it was in a server component, you would need a separate client component for provider to pass functions:
'use client';
import { RootProvider } from 'fumadocs-ui/provider/<framework>';
import SearchDialog from '@/components/search';
import type { ReactNode } from 'react';
export function Provider({ children }: { children: ReactNode }) {
return (
<RootProvider
search={{
SearchDialog,
}}
>
{children}
</RootProvider>
);
}How is this guide?
Last updated on
