Search

The default theme supports Algolia DocSearch through docsearch and custom search components through search, including @sveltepress/meilisearch.

Algolia DocSearch

Pass a docsearch config object to defaultTheme to enable Algolia DocSearch in the navbar.

Required fields are appId, apiKey, and indexName. Every other DocSearch option is also accepted.

vite.config.(js|ts)
import {  } from '@sveltepress/theme-default'
import {  } from '@sveltepress/vite'
import {  } from 'vite'

export default ({
  : [
    ({
      : ({
        : {
          : 'YOUR_APP_ID',
          : 'YOUR_SEARCH_API_KEY',
          : 'YOUR_INDEX_NAME',
        },
      }),
    }),
  ],
})
ts
Apply for DocSearch

DocSearch is free for open-source documentation sites. Apply at docsearch.algolia.com .

Meilisearch

@sveltepress/meilisearch is the supported Meilisearch search component. Install it first:

npm install --save @sveltepress/meilisearch
sh

Create a wrapper that provides your Meilisearch connection settings:

src/lib/MeilisearchSearch.svelte
<script lang="ts">
  import  from '@sveltepress/meilisearch/Search.svelte'
</script>

<
  ="https://search.example.com"
  ="YOUR_SEARCH_ONLY_KEY"
  ="docs"
/>
svelte

Then pass the wrapper path to the default theme's custom-search hook:

vite.config.(js|ts)
import {  } from '@sveltepress/theme-default'

({
  : '/src/lib/MeilisearchSearch.svelte',
})
ts

The component queries an existing Meilisearch index; it does not build the index for you. Each record should provide id, title, content, and either url or path. Use a search-only API key in browser code.

Known production build bug

The custom-search API and @sveltepress/meilisearch component are supported, and the source-path setup above works in development. However, the current default-theme runtime leaves the .svelte path as a browser import, so a static production build does not bundle that wrapper. Passing a component object directly is also ineffective because theme-option serialization removes it. This is a default-theme bundling bug, not a lack of M Search support. Verify the production deployment until the runtime integration is fixed.

For another search provider, implement the same search hook with your own Svelte wrapper. If both search and docsearch are configured, search takes precedence.

Last update at: 2026/08/25 17:18