<!--
Sitemap:
- [What is Vocs](/introduction/what-is-vocs): Learn why Vocs exists and when to use it
- [Getting Started](/introduction/getting-started): Install Vocs and create your first documentation site
- [Project Structure](/introduction/project-structure): Overview of the structure of a Vocs project
- [Writing Docs with AI](/introduction/writing-docs-with-ai): Use an AI agent to create and maintain Vocs documentation
- [Markdown Extensions](/writing/markdown-extensions): Features and syntax of Markdown in Vocs
- [Code & Syntax Highlighting](/writing/syntax-highlighting): Rich markup and annotations for code
- [Twoslash](/writing/twoslash): Add type-aware annotations to code examples
- [Code Snippets](/writing/code-snippets): Include and reuse code in Markdown
- [Markdown Snippets](/writing/markdown-snippets): Include other Markdown files in MDX
- [React in Markdown](/writing/react): Compose MDX pages with React components
- [Mermaid Diagrams](/writing/mermaid): Render diagrams from text using Mermaid
- [Assets](/writing/assets): Manage images, fonts, icons, and other docs assets
- [Frontmatter](/writing/frontmatter): Configure page metadata, layouts, search, and UI visibility
- [Navigation](/features/navigation): Keep docs navigation synced with routes
- [Search](/features/search): Built-in client-side search powered by MiniSearch
- [Layouts](/features/layouts): Choose and customize page shells for your docs
- [Slots](/features/slots): Inject custom components into the docs shell
- [Theming](/features/theming): Customize colors, typography, spacing, logos, and code themes
- [Tailwind CSS](/features/tailwind): Use Tailwind utilities in Vocs pages and components
- [Dynamic OG Images](/features/dynamic-og-images): Generate social preview images from page metadata
- [Page Feedback](/features/feedback): Collect page-level feedback from readers
- [Redirects](/features/redirects): Preserve old URLs and route legacy paths to new locations
- [API Routes](/features/api-routes): Add server-rendered endpoints to your docs site
- [Agent Support](/features/agent-support): Serve documentation in machine-readable form for AI agents
- [Ask AI](/features/ask-ai): Built-in AI assistant menu on every page
- [MCP Server](/features/mcp-server): Expose your docs and source code to AI assistants
- [Changelog Generation](/features/changelog-generation): Fetch release notes and render a changelog page
- [Site Configuration](/reference/site-config): Reference for options accepted by defineConfig
- [Frontmatter Reference](/reference/frontmatter): All frontmatter fields accepted by a Vocs MDX page
- [Components](/reference/components): Reference for the public React components exported from Vocs
- [Hooks](/reference/hooks): Reference for the React hooks exported from Vocs
- [Changelog](/changelog): Release history for Vocs
-->

# Search \[Built-in client-side search powered by MiniSearch]

Vocs ships a built-in search dialog. It indexes every MDX page at build time, ships the index to the client, and runs queries entirely in the browser — no third-party service required.

## Opening Search

* Click the search input in the top navigation, or
* Press `⌘K` / `Ctrl+K` to focus the dialog from anywhere.

Search supports keyboard navigation (`↑` `↓` `Enter`), fuzzy matching, "Jump to" suggestions, and a list of recently viewed pages.

## How It Works

At build time, Vocs walks `src/pages/`, splits each MDX page into title/subtitle/text/category fields, and builds a [MiniSearch](https://lucaong.github.io/minisearch/) index. The index is written to `.vocs/search-index-{hash}.json` for production and served as a virtual module in dev with HMR.

At runtime, the index is fetched once on first search and stays in memory for the session.

## Configuration

Customize search behavior in `vocs.config.ts`:

```ts twoslash
import { defineConfig } from 'vocs/config'

export default defineConfig({
  search: {
    fuzzy: 0.2,
    prefix: true,
    combineWith: 'AND',
    boost: { title: 4, subtitle: 3, text: 2, category: 1, titles: 1 },
  },
})
```

### Options

#### `fuzzy`

* **Type:** `number | boolean`
* **Default:** `0.2`

Tolerance for typos. A number between `0` and `1` controls the fuzziness ratio. Set `false` to require exact matches.

#### `prefix`

* **Type:** `boolean`
* **Default:** `true`

When `true`, queries match terms that share a prefix (so `nav` matches `navigation`).

#### `combineWith`

* **Type:** `'AND' | 'OR'`
* **Default:** `'AND'`

How to combine multiple search terms. `AND` (the default) requires every term to match.

#### `boost`

* **Type:** `Record<string, number>`

Boost factor per indexed field. Defaults:

| Field | Boost |
|---|---|
| `title` | 4 |
| `subtitle` | 3 |
| `text` | 2 |
| `titles` | 1 |
| `category` | 1 |

#### `boostDocument`

* **Type:** `(id: string, term: string, storedFields?: Record<string, unknown>) => number`

Custom function for boosting documents. Vocs's default boosts shallower routes and prefers `/docs/*`. Override to implement your own ranking heuristic.

## Per-Page Boosting

Use the `searchPriority` field in [frontmatter](/reference/frontmatter) to boost or hide a page:

```mdx
---
searchPriority: 5    # higher = ranked higher
---
```

Set `searchPriority: 0` to exclude a page from search entirely.

## Hiding the Search Box on a Page

```mdx
---
showSearch: false
---
```

This hides the search trigger only on the affected page; the keyboard shortcut still opens the dialog.

## Local Caching

In production, the search index file is content-hashed (`search-index-{hash}.json`) so browsers and CDNs can cache it indefinitely. When you redeploy with content changes, a new hash invalidates the cache automatically.

## See Also

* [Frontmatter reference](/reference/frontmatter) — `searchPriority`, `showSearch`
* [Site Configuration](/reference/site-config#search) — full option types
