c/frontend › command
0votes

Debounced Live Search

PromptLow risk
submitted by CommandVault editors to c/frontend · 6 uses

Reduce server load while users type

Prompt · 2 variables
Add live search that updates as people type without overloading the server.

Stack: {{stack}}
Search covers: {{goal}}

Requirements:
1. Debounce input by about 300 ms and send one request with the final query.
2. Cancel in-flight requests when a newer query starts, so older results never overwrite newer ones.
3. Skip requests for queries shorter than 2 characters; trim whitespace.
4. Show loading, empty ("No results for …") and error states, and keep the previous results visible while the next ones load.
5. Make results keyboard-navigable (arrow keys, Enter, Escape) and announce the result count to screen readers.
6. Reflect the query in the URL so searches can be shared and the back button works.

Explain how to verify it: what the network tab should show while typing quickly, and the edge cases you tested.
e.g. 'products by name and SKU' or 'help articles'
Framework, language and versions, e.g. Next.js 16 App Router + TypeScript
0 commentsreport

Try it here

Fill in {{goal}} above first for a better answer, or run it as is and the AI will assume sensible values.

or open in ChatGPT · Claude · Perplexity

How to use this prompt

  1. Fill in the 2 blanks above. The more specific you are, the better the answer.
  2. Copy it and paste it into ChatGPT, Claude, Gemini, Cursor or Codex, or use "Try it here" for a quick test.
  3. Read the answer critically: check anything it claims about your code or data before you rely on it.
  • {{goal}} e.g. 'products by name and SKU' or 'help articles'
  • {{stack}} Framework, language and versions, e.g. Next.js 16 App Router + TypeScript

More from c/frontend

See all of c/frontend →
0 comments

Log in to join the discussion.