Static site search for Astro in 2026: why I picked Pagefind over Algolia and Lunr In 2026, the author chose Pagefind over Algolia and Lunr.js for adding search to three AI-curated directory sites, primarily due to its efficient index size management and zero cost. Pagefind is a Rust-based static search library that generates a sharded index at build time, loading only small chunks (under 30KB initially) as users type, unlike Lunr which would require shipping a 2-4MB index per page load. Additionally, Pagefind's static file deployment model eliminates API keys, per-query billing, and service dependencies, fitting the author's total infrastructure budget of $25/month for three sites. I added search to all three of my AI-curated directory sites https://dev.to/articles/three-sites-experiment last month. The choice wasn't obvious — there are at least four options with real adoption — so here's the breakdown I actually ran through before landing on Pagefind https://pagefind.app/ . The four options I considered Pagefind is a Rust-based static search library. It runs at build time, generates an index in / pagefind/ , and serves everything as static files. No backend, no API key, no per-query billing. It ships a prebuilt UI PagefindUI that you can mount on any element, and it supports WebAssembly for in-browser querying. Algolia DocSearch is free for open-source documentation sites, $49/month for commercial sites below a certain crawl limit. It indexes your content via their crawler or an API push , stores it on Algolia's infrastructure, and gives you a hosted search widget. Fast, polished, and battle-tested — it's what most major docs sites use. Lunr.js is a client-side search library. You build the index at build time, serialize it to JSON, and ship it with the page. The browser loads the entire index on first search. Works offline, no external dependency, but the index size grows linearly with content, and there's no incremental loading. FlexSearch is a newer alternative to Lunr with better performance characteristics and smaller bundle size, but the same core trade-off: you ship the whole index to the browser upfront. Why Pagefind won The decisive factor was index size management. My directories have 500-1,000 entries per site, each with a multi-paragraph generated description. A Lunr index for 1,000 entries would be 2-4MB shipped with every page load. Pagefind shards its index and loads chunks lazily as the user types — so the initial load is under 30KB the WASM binary + a small manifest , and individual chunk fetches happen on demand. The second factor was cost. Algolia DocSearch's commercial tier runs $49/month per site. I'm running three sites on a total infrastructure budget of roughly $25/month https://dev.to/articles/static-ssg-vs-dynamic-ai-rendering-directory-seo . Pagefind is free. The third factor was the deploy model. Because everything in / pagefind/ is a static file, Cloudflare Pages caches it at the edge with no configuration. There's no API to rate-limit, no service availability to depend on, no API key to rotate. The SearchDialog implementation The search component is a