Repo

astro-d1-search

Site search for Astro, backed by Cloudflare D1 (SQLite FTS5): build-time indexing, an injected search API, bm25 + recency ranking.

Running in production on zander.wtf/search — see theExamples guide for its full source.

What you get

  • Build-time indexing of any markdown or MDX — content collections, standalone pages, anything on disk — into a D1 full-text index.
  • An injected API endpoint (GET /api/search) with bm25 + recency ranking, highlighted snippets, type filtering, input validation and edge caching.
  • A query function (searchIndex) for server-rendered search pages that hit the D1 binding directly, with no HTTP round trip.
  • Content-type agnostic: types are strings you choose, so one index can serve site-wide search, per-section search, and even several sites at once.

Requires the @astrojs/cloudflare adapter. The rest of your site stays fully static — only the search endpoint runs server-side.

Guides

Reference

Theme

Copy this CSS to your project: