npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@monlite/fts

v0.5.2

Published

Full-text search for @monlite/core, powered by SQLite FTS5. Adds collection.search().

Readme

@monlite/fts

Full-text search for @monlite/core, powered by SQLite's built-in FTS5. Adds collection.search().

A monlite plugin — pass it to createDb, point it at the fields you want indexed, and it maintains an FTS5 index automatically on every write, including changes applied by @monlite/sync.

import { createDb } from "@monlite/core";
import { fts } from "@monlite/fts";

const db = createDb("./app.db", {
  plugins: [fts({ posts: ["title", "body"], users: ["name", "profile.bio"] })],
});

await db.collection("posts").create({
  data: { title: "Hello world", body: "the quick brown fox" },
});

const results = await db.collection("posts").search("quick");
// [ { _id, title, body, _score, … } ]  — ranked, full documents returned

Install

npm install @monlite/core @monlite/fts

No native dependency — FTS5 is built into SQLite, so this works on both monlite backends (better-sqlite3 and the built-in node:sqlite).

API

Plugin

fts(spec: Record<string, string[]>): MonlitePlugin

spec maps a collection name to the field paths to index. Dot-notation is supported for nested fields (e.g. "profile.bio").

search

collection.search(query: string, {
  limit?: number,           // default 50
  where?: WhereInput<T>,    // combine with a normal monlite filter
}): Promise<Array<WithId<T> & { _score: number }>>
  • query uses FTS5 MATCH syntax: bare terms are AND-ed, "a phrase", term* prefix, a OR b.
  • Results are ordered by relevance; _score is higher = better.
  • where is applied after matching, so you can combine FTS with structured filters.

Reindex

import { reindex } from "@monlite/fts";
reindex(db, "posts", ["title", "body"]); // rebuild a collection's index

Dynamic index — createSearchIndex(db)

The fts() plugin attaches collection.search() with a static spec. For a programmatic index over collections created at runtime — RAG, per-tenant search — use createSearchIndex(db):

import { createSearchIndex } from "@monlite/fts";

const idx = createSearchIndex(db);
idx.ensureCollection("docs", { fields: ["title", "body"], filterFields: ["docId"] });
idx.upsert("docs", [{ id: "c1", fields: { title, body }, filters: { docId: "d1" } }]);
idx.search("docs", "hello world", { where: { docId: "d1" } }); // scoped to one case/tenant

Each collection is its own FTS5 table; filterFields are UNINDEXED columns so a where scopes the MATCH without affecting ranking. Synchronous.

How it works

For each configured collection, the plugin creates an FTS5 virtual table (<collection>_fts) keyed by the document _id. It backfills existing documents on init (when the index is empty) and keeps it current via the plugin afterWrite hook. Search runs MATCH against that table and returns the live documents in rank order.

Multi-process freshness

The afterWrite hook only sees writes made through its own connection. If a separate process writes documents (e.g. an ingest worker), call collection.catchUp() in the searching process to incrementally index what changed and reconcile cross-process deletes — no full reindex:

db.collection("posts").catchUp(); // → { indexed, removed }; call periodically
await db.collection("posts").search("hello");

catchUp tracks an updated_at high-water-mark, so each call only processes new work.

License

MIT