Search

Search questions, topics, and tracks

0

Build a typeahead search box

  • Frontend
  • 60 min
  • medium
  • React · TypeScript
The brief — 60 minutes

We have a search endpoint and a text input. Wire them together the way a product would ship it: results appear as the user types, the list is usable from the keyboard, and a slow response can never overwrite a newer one. Start from an empty component and talk through the trade-offs as you go.

Requirements

  • Results update as the user types, hitting GET /search?q= — no submit button.
  • Do not fire a request per keystroke; the interviewer will ask what you chose and why.
  • A slow response for an older query must never replace results for a newer one.
  • The list is navigable with ↑ ↓, chosen with Enter, dismissed with Escape.
  • Loading, empty and error states are all visible — no silent failures.
  • Screen readers announce the result count as it changes.
Open a starter sandbox

Stage 1 of 5 · ~5 min

Clarify before you type

Turn a vague prompt into written assumptions

Nobody hires the candidate who starts typing at second zero. Two minutes of questions is the cheapest part of the hour, and it is the part that decides whether the rest is right.

Ask these, in this order:

  • How large is the result set? Ten rows and a thousand are different components.
  • Is the endpoint debounced or rate-limited server-side? It changes what your client has to protect against.
  • Does selecting a result navigate, or fill the input? This decides whether you need controlled selection state at all.
  • Do we own the markup, or is this dropping into a design system? Decides whether you hand-roll the combobox or wire one up.

For the rest of this walkthrough: a few hundred rows at most, no server-side throttling, selecting fills the input, and we own the markup.

5 of 60 min

Once you finish

The follow-on asks that arrive when you are done early.

  • Cache per query string so retyping a prefix is instant.
  • Highlight the matched substring inside each result.
  • Recover from a failed request with a retry that doesn't lose the typed query.
  • Virtualise the list once results run past a few hundred rows.

What this tests

  • async-state
  • race-conditions
  • accessibility
  • keyboard-interaction
  • caching

Brush up first

Reviewed 24 August 2026