@sprigr/browser
v1.0.2
Published
Sprigr browser search engine — WASM full-text, faceted and hybrid semantic search that runs entirely client-side.
Maintainers
Readme
@sprigr/browser
The Sprigr search engine compiled to WebAssembly. Full-text, faceted and hybrid semantic search running entirely in the browser: you download a binary index once, then every keystroke is answered locally with no network round trip.
Built from the browser-wasm crate in
sprigr/sprigr-search. Every target
below is produced from one source tree in a single build, so they are always
the same engine.
Targets
| Entry | wasm-pack target | Use it for |
|---|---|---|
| @sprigr/browser | bundler | webpack, vite, rollup, and the Workers loader |
| @sprigr/browser/web | web | serving the .wasm as a static asset and calling init(url) |
| @sprigr/browser/nodejs | nodejs | CommonJS on the server |
Bundler
import init, { SearchEngine } from '@sprigr/browser';Static asset (Next.js and friends)
The web build is for apps that serve the engine from their own origin rather
than bundling it. Copy the three files into your public directory at build
time, then load them at runtime:
const wasm = await import('/wasm/sprigr_browser.js');
await wasm.default({ module_or_path: '/wasm/sprigr_browser_bg.wasm' });
const engine = new wasm.SearchEngine();
engine.configure(JSON.stringify({ searchable_attributes: ['name'] }));
engine.load_binary_index(bytes);
const results = JSON.parse(engine.search('conditioner', '', 24, 0));Pass init an object rather than a bare URL string. The bare-string form still
works but logs a deprecation warning from wasm-bindgen.
Node
const { SearchEngine } = require('@sprigr/browser/nodejs');Sharded indexes
Large catalogues arrive as several shards. Load them in order, then call
finalize_shards() once:
shards.forEach((bytes, i) => engine.load_binary_index_shard(bytes, i));
engine.finalize_shards();finalize_shards() is retained as a no-op for callers written against older
versions, which used it to materialize prefix entries.
Versioning
The npm version tracks the browser-wasm crate version. Published releases
carry npm provenance, so the exact commit and workflow run that produced a
given version are verifiable on the package page.
