Why static HTML has no native backend search bar out of the box
A dynamic CMS queries MySQL tables whenever a visitor presses Enter. Prebuilt static hosting serves saved HTML directly, so search uses pre-indexed metadata chunks instead.
Option 1: Static post-build search with Pagefind (Zero server cost)
Running Pagefind right after astro build scans your rendered dist/ HTML, chunks tiny WebAssembly search indexes, and only downloads relevant fragments when a visitor actually types into the search box.
npx astro build && npx pagefind --site dist
Option 2: Compact JSON or Cloudflare D1 FTS5 API
For small 20–100 item catalogs or MCP endpoint searches, filtering a compact build-time JSON index or querying SQLite FTS5 inside D1 keeps bundle sizes tiny cleanly.
Common questions
Will adding Pagefind slow down page loads for visitors who don't search?
No—when loaded lazily on input focus, initial landing pages remain completely unaffected.
When do you outgrow static Pagefind search?
Only on huge user-generated directories, private permissioned search results, or real-time pricing filters across 50,000+ inventory items—where D1 FTS5 or dedicated search backends fit better.
References
Provider interfaces and limits can change. Consult the original documentation before changing production settings.