Skip to content
fa
Search Frontend Atlas
Search questions and concepts across the handbook.
Frontend System Designadvanced13 min read

How would you design search for a content-heavy frontend?

Decompose indexing, retrieval, ranking, interaction, URL state, accessibility, and failure behavior.

Useful prerequisites

Search looks like an input and a list of results, but the experience begins before the first character is typed and continues after results appear. Empty queries, slow responses, no matches, keyboard navigation and stale results all shape whether search feels dependable. The architecture needs to account for those states, not only the ranking function.

Search looks like an input and a list of results, but the experience begins before the first character is typed and continues after results appear. Empty queries, slow responses, no matches, keyboard navigation and stale results all shape whether search feels dependable. The architecture needs to account for those states, not only the ranking function.

The quick version

For a static content corpus, generate a compact search index at build time and query it client-side. For large or frequently changing corpora, consider a dedicated search service. The design should preserve shareable query state and accessible result navigation.

Build the mental model

Search architecture depends on corpus size, freshness, ranking quality, privacy, and offline needs. Static search avoids a backend and keeps content deployable, but index size and client CPU must be measured. Debounce input, cancel obsolete work, and handle no-results and loading states.

See it in code

interface SearchDocument {
  id: string;
  title: string;
  url: string;
  terms: readonly string[];
}

Where it gets tricky

Ranking should match the corpus and reader intent: exact title matches usually deserve more weight than incidental body mentions. Normalize query input, cap result count, and provide keyboard-accessible links. Keep query state in the URL if search results should be shareable. For a static corpus, rebuild the index with the content rather than introducing runtime infrastructure prematurely.

A common misunderstanding

Adding a search box does not create a useful search system; ranking, discoverability, and empty-state behavior matter.

What this changes in an application

For Frontend Atlas, a generated JSON index is a good initial fit: deterministic, versioned with the content, and served as a static asset.

Questions worth exploring next

  • How would you evolve to 100,000 documents?
  • How do you prevent stale results from racing?

References and next steps

  • Search user experience — primary or authoritative documentation for the underlying behavior.
  • MDN Web Docs — use the relevant API reference for adjacent browser details.

Explore next