Skip to main content
Add semantic search to your VitePress documentation site using the vitepress-plugin-moss package. The plugin automatically indexes your content at build time and replaces the default search with a fast, semantic search interface powered by Moss.
Note: For the full plugin source and a demo site, see the vitepress-plugin-moss package.

Why use Moss with VitePress?

VitePress’s built-in search relies on keyword matching, which misses results when users phrase queries differently than the docs. Moss semantic search understands meaning, so users find what they need even when their wording doesn’t match the docs exactly. Queries run in under 10ms once the local index loads.

Required tools

Integration guide

1

Installation

Your project’s package.json must have "type": "module" because VitePress is ESM-only.
2

Environment setup

Create a .env file in your project root (add it to .gitignore).
.env
3

Configure VitePress

Add the Moss plugin and search options to your VitePress config.
docs/.vitepress/config.ts
4

Build and test

When you run vitepress build, the plugin automatically parses your Markdown, chunks it into semantic segments, and uploads them to Moss. For local development, start the dev server and press Ctrl+K or Cmd+K to test search.

How it works

The plugin uses a two-phase search architecture:
  1. Cloud hot-path — From the first keystroke, queries route to Moss cloud for instant results.
  2. Local WebAssembly — In the background, the local model and index download in parallel. Once ready, queries switch to sub-10ms on-device search automatically.

Excluding pages

Add search: false to a page’s frontmatter to exclude it from the index.

Configuration

Search options

All options go under themeConfig.search.options in your VitePress config.

Keyboard shortcuts