Search
Implement document search in your docs
Search UI
See Search UI to learn how to customize the UI of document search.
Search Client
You can choose & configure the search client according to your search engine, it defaults to ZBSearch.
ZBSearch (default)
The default search engine powered by ZBSearch.
Algolia
Using Algolia with Fumadocs UI.
FlexSearch
A fast & minimal search engine.
Meilisearch
Using Meilisearch with Fumadocs UI.
Mixedbread
Using Mixedbread with Fumadocs UI.
Orama Cloud
Using Orama Cloud with Fumadocs UI.
Typesense
Using Typesense with Fumadocs UI.
Custom Search
For other search solutions.
Search Hooks
Search clients come with React hooks, like useFetchSearch() and useAlgoliaSearch(), returning the props of <SearchDialog />:
import { useFetchSearch } from 'fumadocs-core/search/client';
const search = useFetchSearch();
<SearchDialog {...search} {...props} />;Along with search and onSearchChange for the search input, they return:
data: the last successful search, kept while searching again and after an error.items: its results, with their content also parsed as hast ashastContent. The rows of a table are grouped into atableitem.query: the query it searched for.
error: set when the last search failed.isLoading: whether a search forsearchis pending.
For other search engines, pass a memoized search function to experimental_useSearch(), it searches again when the function changes.
'use client';
import { useCallback } from 'react';
import { experimental_useSearch } from 'fumadocs-core/search/client';
import type { SortedResult } from 'fumadocs-core/search';
export function useMySearch(locale: string) {
const search = useCallback(
async (query: string): Promise<SortedResult[]> => {
const res = await fetch(`/api/my-search?${new URLSearchParams({ query, locale })}`);
return res.json();
},
[locale],
);
return experimental_useSearch(search);
}Community Integrations
A list of integrations maintained by community.
How is this guide?
Last updated on
