Skip to main content
Introducing packages.sweber.dev
All packages
BetaMIT + Pro

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/transformers

Most 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

  • 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 plus cosine similarity on embeddings
  • Instant keyword results, semantic ranking as soon as the model is loaded, keyword-only for visitors who save data
  • Compact int8 vectors: about 400 bytes per section
  • 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

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
  • Search insights without tracking: queries without results, results nobody opened, HTML and Markdown report

Compare

Free and ProSide by side.

FeatureFreePro
Index builder, CLI and hybrid searchIncludedIncluded
Web component and React bindingsIncludedIncluded
English and multilingual models, self-hostingIncludedIncluded
Index in every Vite build, dev server and rebuild on changeNot includedIncluded
Embedding cache for fast rebuildsNot includedIncluded
Search insights and reportNot includedIncluded
LicenceMITPer person
SupportGitHub issuesAgency and Lifetime

Pro

Pro packagesAdd-ons on top of the core.

Live demo

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-vite

    Vite plugin that builds the index with every build, serves it in dev and re-embeds only changed sections.

  • @weber-development/cosine-insights

    Records searches without cookies or ids and reports queries without results and results nobody opened.

Pricing

PricingPrices are in CHF.

Freelancer

For one person working on client projects.

CHF 90

per year

2 months free

  • 1 person
  • No support entitlement
Subscribe

Agency

Recommended

For teams of up to ten named people, one price.

CHF 290

per year

2 months free

  • Up to 10 people
  • Support included
Subscribe

Lifetime

Pay once for up to ten people and keep updates and repository access.

CHF 990

one-time

  • Up to 10 people
  • Support included
Buy lifetime licence

11 people or more: get in touch

  • 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.
Read the licence terms

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.