Skip to main content
Run indexing and queries inside a browser extension using the @moss-dev/moss-web SDK. The background service worker hosts the Moss client and the index; content scripts message the worker to run queries. The index persists in extension storage or IndexedDB, so queries resolve in the browser without a network call and the indexed data stays in the browser. A million 256-dimension vectors compress to roughly 500 MB; most extensions need far less.

Architecture

  • Background service worker hosts a Moss client (use the browser SDK, @moss-dev/moss-web)
  • Content scripts post messages to the background worker for index/query
  • Persist the index using extension storage or IndexedDB

Example (background worker)

// background.ts
import { MossClient } from '@moss-dev/moss-web'
const client = new MossClient(process.env.MOSS_PROJECT_ID!, process.env.MOSS_PROJECT_KEY!)

chrome.runtime.onMessage.addListener(async (msg, _sender, sendResponse) => {
  if (msg.type === 'query') {
    await client.loadIndex('ext-context')
    const res = await client.query('ext-context', msg.text, { topK: 3 })
    sendResponse(res)
  }
})

Browser SDK

The in-browser @moss-dev/moss-web client.

Local embeddings

Embed on-device for privacy.