Payload Logo

Client-Side Search Is a Static Site's Best Trick

Date Published

Interior view of multiple library shelves stacked with books, featuring glass panels and architectural elements

A search index built at the same time as the static export — rather than queried live against a database — turns search into just another static asset: downloaded once, then queried instantly in the browser with no round trip per keystroke.

The trade is index size versus content volume: this works well for a site with a few thousand pages and gets genuinely impractical for a site with a few million, at which point a hosted search service is the more honest answer. Most sites reaching for this pattern are well inside the range where it works.

The result, when it fits, is search that feels faster than most server-backed implementations, for the unglamorous reason that there's no network latency in the loop at all — just a lookup against data the browser already has.