CosineSemantic search for documentation sites that runs entirely in the browser. No search server, no API key, no query leaves the device.
pnpm add @sweberdev/cosine @huggingface/transformersMost docs search either needs a hosted service or matches only exact words: someone who types "how do I get rid of the app" finds nothing on a page called "Uninstall". Cosine closes that gap without a server. cosine build splits your Markdown, MDX or HTML pages at their headings and stores a small vector per section next to your site. In the browser, keyword results appear on the first keystroke, and once the embedding model has loaded (about 23 MB, cached) the ranking combines keywords and meaning.
The search field is an accessible web component in English, German, French and Italian that works in any framework, with React bindings on top. Queries are never sent anywhere, and the model can be served from your own domain.
Example
A short exampleCopy it into your project.
Build the index, add the field
<!-- npx cosine build docs --out public/cosine --base-url /docs -->
<script type="module">
import "@sweberdev/cosine/element"
</script>
<cosine-search index="/cosine/cosine-index.json" lang="de"></cosine-search>Features
What you getFree under MIT, with Pro on top.
Free, MIT
- Semantic search that runs entirely in the browser, no server or API key
- Hybrid ranking: keywords with typo tolerance plus embeddings
- Index builder and CLI for Markdown, MDX and built HTML
- Web component and React hooks in 4 languages
- Scoped search, facets, synonyms and boosting
Pro
- Everything in Free
- Plugins for Vite, Next.js, Docusaurus, VitePress and Astro
- Search insights without tracking: queries without results and trends
- Gap suggestions, weekly report and golden-query tests
- Short answers quoted from your docs
- Algolia migration and one index per language
All features in detail
Free, MIT
- Index builder and CLI for Markdown, MDX and built HTML, split at headings with deep links
- Hybrid ranking in the browser: BM25 keyword search with prefix matching and typo tolerance, plus cosine similarity on embeddings
- Instant keyword results, semantic ranking as soon as the model is loaded, keyword-only for visitors who save data
- Scoped search: limit a search field to parts of the site, e.g. only the API reference
- Synonym lists stored in the index, so "login" also finds "sign in", even before the model has loaded
- Incremental builds in the CLI: --incremental embeds only new and changed sections
- Facets: result counts per section of the site, for search pages with filters
- Search syntax for visitors: "exact phrases" and -excluded words, also in the semantic ranking
- Boosting: rank sections of the site higher or lower, stored in the index
- Several indexes in one search field (index="/docs.json /blog.json"), merged into one result list
- Facet filter buttons in the web component: a row of sections with counts that narrows the results
- Tested in real Chromium on every release: keyboard use, ARIA, narrow screens, reduced motion and an axe-core scan against WCAG 2.1 AA
- Benchmarks with fixed limits in CI: bytes per section, bytes per vector and search time over 3000 sections
- Frozen public API: a test lists every export, attribute, part and CLI option, so 2.x cannot break them silently
- Guides for migrating from Pagefind, Orama, MiniSearch and Lunr, framework recipes, troubleshooting and a nightly real-model test
- Compact int8 vectors: about 400 bytes per section, or half that with 4-bit vectors (--vector-bits 4)
- Accessible <cosine-search> web component (ARIA combobox) in English, German, French and Italian
- React component and hooks, English or multilingual models, model self-hosting for GDPR and FADP
- Index format 2: a compact manifest, and large sites can split the index into shards (--shard-size) that the browser loads in parallel and that stay cached when only one part changed
- Build integrations for Docusaurus, Astro and VitePress as subpath exports, with indexFiles() for your own build tools
- Word splitting with Intl.Segmenter for Chinese, Japanese, Thai and other scripts written without spaces, and accent folding that respects each script
- Tested in Chromium, Firefox and WebKit on every change
Pro
- Vite plugin: the index builds itself in Vite, Astro, VitePress, SvelteKit and Nuxt, and in dev
- Embedding cache: a rebuild embeds only the sections that changed
- Next.js integration: the index is built from the prerendered pages after next build, kept in .next/cache so CI rebuilds embed only what changed
- Algolia migration: cosine-migrate turns a DocSearch export and its synonyms into a Cosine index, no new crawl
- Search insights without tracking: queries without results, results nobody opened, as HTML, Markdown or CSV
- Insights trends: new and resolved gaps, rising queries and a weekly chart, compared with the period before
- Gap suggestions: for every query without results, whether it is a typo, which pages come closest, or that a page is missing (cosine-insights suggest)
- Weekly search report: a ready-made GitHub Action opens trends and gaps as an issue every Monday
- Short answers: cosine-answers quotes the sentence that answers the question above the results, without an LLM
- Insights dashboard: one HTML file with overview, gaps with fixes, weekly trends, top content and CSV downloads
- Golden-query quality tests: cosine-quality check fails CI when a query that used to find the right page stops doing so, and reports what moved
- Synonym pull requests: cosine-insights synonyms turns queries without results into a reviewable list of synonym suggestions, ready for a weekly Action to open as a PR
- Answers in several languages: stemmers for English, German, French, Italian, Spanish, Dutch and Portuguese, so the quoted sentence matches inflected words
- Docusaurus plugin and search bar theme: the index per locale with embedding cache and shards, and a search field that replaces the built-in one
- VitePress: one config wrapper and a theme that puts the search field in the nav bar, with VitePress locales mapped to languages
- Astro and Starlight: an integration and a Starlight plugin that replaces the built-in search
- Models per page language: one index per language, English pages with the 23 MB model and other languages with the multilingual one, so visitors download only the model of the language they read (cosine-i18n)
| Feature | Free | Pro |
|---|---|---|
| Index builder, CLI and hybrid search | Included | Included |
| Web component and React bindings | Included | Included |
| English and multilingual models, self-hosting | Included | Included |
| Index in every Vite build, dev server and rebuild on change | Not included | Included |
| Embedding cache for fast rebuilds | Not included | Included |
| Search insights and report | Not included | Included |
| Licence | MIT | Per person |
| Support | GitHub issues | Agency and Lifetime |
Pro
Pro packagesAdd-ons on top of the core.
Try the themes, browse the catalog and read a real scanner report. The demo also shows the GTM container check, the monitoring of many client sites and the catalog changes per project.
@weber-development/cosine-viteVite plugin that builds the index with every build, serves it in dev and re-embeds only changed sections.
@weber-development/cosine-insightsRecords searches without cookies or ids and reports queries without results and results nobody opened.
@weber-development/cosine-qualityGolden-query tests for CI: fails when a search regression moves the right page down.
@weber-development/cosine-docusaurusDocusaurus plugin and search bar theme, index per locale.
@weber-development/cosine-vitepressVitePress config wrapper and theme with the search field in the nav bar.
@weber-development/cosine-astroAstro integration and Starlight plugin that replaces the built-in search.
@weber-development/cosine-i18nOne index per page language, each with its own model, picked by the page language in the browser.
Pricing
PricingPrices are in CHF.
Freelancer
For one person working on client projects.
CHF 120
per year
2 months free
- 1 person
- No support entitlement
Agency
RecommendedFor teams of up to ten named people, one price.
CHF 390
per year
2 months free
- Up to 10 people
- Support included
Lifetime
Pay once for up to ten people and keep updates and repository access.
CHF 1’290
one-time
- Up to 10 people
- Support included
11 people or more: get in touch
- Pay yearly and get two months free: CHF 120 instead of CHF 144 for Freelancer, CHF 390 instead of CHF 468 for Agency.
- After cancelling, every version you already received keeps working. Only updates and repository access end.
- No licence key, no phone-home. The Pro packages never contact a server to check your licence.
- Agency and Lifetime cover up to ten named people for one price: you choose the number of seats at checkout and assign them in Polar. Your clients and their websites need no licence of their own.
- Checkout, invoices and VAT are handled by Polar as merchant of record.
FAQ
QuestionsShort answers.
Does it need a server or an API key?
No. The index is a static file next to your site and the model runs in the visitor's browser through transformers.js.
How big is the download?
The library is about 7 KB gzip. The index needs about 400 bytes per section. The English model is about 23 MB, loaded only when the search field gets focus and then cached by the browser.
Is it compliant with the GDPR and the Swiss FADP?
Queries never leave the browser. The model is downloaded from Hugging Face by default; serve it from your own domain if that request is a problem for your site. Keyword-only mode contacts no third party at all.
Does it work with German, French or Italian docs?
Keyword search works in every language and folds accents and ß. For semantic search in these languages use the multilingual model, which also matches queries and pages in different languages.
Which frameworks are supported?
Any. The search field is a web component; the index is built from Markdown, MDX or the HTML your site generator produces. React bindings are included, and Cosine Pro adds a Vite plugin.
Can I use the open-source part on its own?
Yes. @sweberdev/cosine and @sweberdev/cosine-react are MIT-licensed and complete without Pro.
Articles
ArticlesGuides and release notes.
2026-10-05
The Compliance Bundle: three Pro add-ons, one licencePermito Pro, Surjection Pro and Logarithm Pro together from CHF 49 a month. New compliance packages join at no extra cost. Also: new prices for Cosine Pro and Derivative Pro.