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

@siftlite/d1

v0.2.0

Published

SiftLite Cloudflare D1 runtime adapter.

Readme

@siftlite/d1

Cloudflare D1 runtime adapter for SiftLite.

This package is a runtime adapter. Search semantics stay in @siftlite/fts5. Core never imports D1 types.

Limits

Documented D1 per-query limits (revalidated 2026-08-16 from D1 platform limits):

| Limit | Value | | --- | --- | | Bound parameters | 100 | | SQL function arguments | 32 | | Statement size | 100,000 bytes | | LIKE/GLOB pattern | 50 bytes | | Query duration | 30 seconds | | Columns per table | 100 |

The adapter exposes these as runtimeCapabilities.limits. Compilers must reserve budget before D1 receives an invalid statement.

Consistency

A plain D1Database binding is not session-aware. Cloudflare currently documents non-session queries as primary-only and requires Sessions to use read replication. readReplicaEligible is false on d1Adapter and true on d1SessionAdapter. A plain binding does not promise post-commit read-your-writes or cross-request session continuity.

Use d1SessionAdapter(db, bookmark) to wrap withSession():

  • first-unconstrained — first query may use any instance
  • first-primary — first query goes to primary
  • a previous session bookmark — sequential consistency from at least that version

getBookmark() returns the latest session bookmark, or null before any query.

D1 batch() is an atomic sequential transaction. Interactive BEGIN/COMMIT callbacks are not part of the Worker API, so transactions is false.

Typo tolerance

D1 is cost-sensitive. D1_DEFAULT_SEARCH_POLICY.typoFallback is disabled-on-cost-sensitive-runtimes. If an index definition requests typoTolerance.mode: "fallback" under that policy, search fails with SEARCH_CAPABILITY_UNSUPPORTED / typo-fallback-unsupported; it does not silently continue as exact-only search. Keep the definition mode "off" or make an explicit enablement and cost decision.

Export / backup of FTS5 indexes

Current D1 export does not support databases containing virtual tables, including FTS5 (import/export known limitations).

Supported workaround:

  1. Drop derived FTS virtual tables (__sift_*_fts, and __sift_*_tri if typo fallback is enabled).
  2. Export the authoritative database (source tables and/or manual document tables).
  3. Recreate/rebuild search structures after import.

Linked indexes are derived from source tables. Do not treat FTS virtual tables as the only backup copy. Manual-mode document tables are ordinary tables and must be included in backups.

Provider Time Travel, replicas, and backups are outside SiftLite's search-visibility deletion guarantee.

Highlight / XSS

Highlighted and formatted strings are not HTML-safe. Do not assign them to innerHTML (or equivalent) without sanitizing. Highlighting is off by default; default markers are markdown **.

Usage

import { d1Adapter, d1SessionAdapter, D1_DEFAULT_SEARCH_POLICY } from "@siftlite/d1";

const adapter = d1Adapter(env.DB);
const session = d1SessionAdapter(env.DB, request.headers.get("x-d1-bookmark") ?? "first-primary");