@moss-dev/moss-web
v1.0.0
Published
Moss browser SDK — in-browser semantic search powered by WASM
Maintainers
Readme
Moss client library for the browser
@moss-dev/moss-web enables private, in-browser semantic search — no server round-trips for queries.
Built on WebAssembly for near-native performance in any modern browser.
Features
- In-Browser Vector Search — Sub-millisecond retrieval with zero network latency
- Semantic & Hybrid Search — Beyond keyword matching
- Multi-Index Support — Manage multiple isolated search spaces
- Full CRUD — Create, update, and delete indexes and documents from the browser
- Privacy-First — Queries run entirely in the browser, no data leaves the device
Installation
npm install @moss-dev/moss-webQuick Start
import { MossClient } from "@moss-dev/moss-web";
// Initialize client (WASM/model download happens automatically on first use)
const client = new MossClient("your-project-id", "your-project-key");
// Create an index with documents
await client.createIndex("knowledge-base", [
{ id: "1", text: "Machine learning fundamentals" },
{ id: "2", text: "Deep learning neural networks" },
]);
// Load the index into browser memory for fast local queries
await client.loadIndex("knowledge-base");
// Query — runs entirely in-browser
const results = await client.query("knowledge-base", "AI and neural networks");
results.docs.forEach((doc) => {
console.log(`${doc.id}: ${doc.text} (score: ${doc.score})`);
});API
Creating a Client
// Simple: lazy initialization (WASM/model loads on first API call)
const client = new MossClient(projectId, projectKey, options?);
// Alternative: eager initialization (WASM/model loads immediately)
const client = await MossClient.create(projectId, projectKey, options?);Options:
model—"moss-minilm"(default, fast, for most use-cases) or"moss-mediumlm"baseUrl— Custom API base URL (for self-hosted Moss instances)
Index Management
// Create index with documents
await client.createIndex(name, docs, options?);
// Create index from files
await client.createIndexFromFiles(name, files, options?);
// Add or update documents
await client.addDocs(name, docs, options?);
// Delete documents by ID
await client.deleteDocs(name, docIds, options?);
// Get index metadata
await client.getIndex(name);
// List all indexes
await client.listIndexes();
// Delete an index
await client.deleteIndex(name);
// Get documents from an index
await client.getDocs(name, options?);
// Check job status for async operations
await client.getJobStatus(jobId);Local Search
// Load index into browser memory for querying
await client.loadIndex(name, options?);
// Check if index is loaded locally
await client.hasIndex(name);
// Get local index info
await client.getIndexInfo(name);
// Query loaded index (runs in-browser)
await client.query(name, queryText, options?);
// Refresh index from server
await client.refreshIndex(name);
// Unload index from browser memory
await client.unloadIndex(name);Cleanup
client.dispose();License
See LICENSE.
