# Search

> A search_documents index kept up by triggers from each config.recordTypes search entry, with search(q) as the caller (websearch, trigram prefixes, can_subject, hybrid with embeddings), search_page for browsing and cursor paging with facet filters, and recents and favorites from the share-links user state.

- Category: Work management
- Module: `search`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/search
- Page: https://bettersupabase.com/blocks/search

## Install

```bash
npx better-supabase add search
```

The command also installs `updated-at`, `memberships`, `permissions`, `subjects`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by search; add installs them too.
    "updated-at": {},
    memberships: {},
    permissions: {},
    subjects: {},
    // Modes: "managed", "custom". The default is "managed".
    search: { mode: "managed" },
  },
});
```

## Client

The React hooks are the registry item `@better-supabase/use-search` (`npx shadcn add @better-supabase/use-search`). They return data and actions and render no UI. Source: https://github.com/ScaleDockHQ/better-supabase/blob/main/packages/registry/items/hooks/use-search.ts

## Related blocks

Requires: [memberships](https://bettersupabase.com/blocks/memberships.md), [permissions](https://bettersupabase.com/blocks/permissions.md), [subjects](https://bettersupabase.com/blocks/subjects.md)

Works with: [share-links](https://bettersupabase.com/blocks/share-links.md), [vector-search](https://bettersupabase.com/blocks/vector-search.md)

## Recipes

- [Command search](https://bettersupabase.com/recipes/command-search.md): A search dialog over the search index, with favorites and recents before the user types.
