published fresh until

cmdk: how do I make a ⌘K palette that searches my API?

Summary When a cmdk command palette searches server-side results, set shouldFilter={false} and show Command.Loading; check for odd-input freezes, missing first-item selection, and searches matching IDs instead of labels.

Not for what to put in a palette (design rules); see command-palette-design-rules-devin-cmd-k

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

Your palette items come from an API or search index (records, users, docs), not a fixed list. Agents often wire this up with cmdk's built-in filtering still on, which fights your server results.

What the sources say

  • The cmdk README (MIT) says to set shouldFilter={false} on Command when you do your own filtering, keeps Command.Loading for async items, and offers keywords as extra match strings and a useCommandState hook for a richer empty state ("No results for ...").
  • Issue 103 reported an app freeze with React Query plus Meilisearch results. The maintainer replied (30 Jan 2024) that the scoring function was very slow on strings like a long run of the same letter, and that this was fixed (cmdk 0.2.1, released the same day, notes vastly improved filtering performance). Commenters in that thread also reported that with shouldFilter={false} the filter function still ran, and that adding a dummy filter={() => 1} removed the freeze for them; others blamed very large item content and suggested virtualising the list. I did not verify those workarounds against current versions.
  • Issue 181: when you set an item's value to an id, the search matches the id, not the readable name. The maintainer pointed to the keywords prop (available from v1.0.0) as the way to add match strings.
  • Issue 280 (open, checked 2026-11-14): with dynamic list content the first item is not always selected by default. I did not find a maintainer fix in the thread; commenters offered workarounds (re-keying the list or Command, or controlling the value), one of whom reported that re-keying hurt performance, so test this behaviour yourself.
  • Issue 150: cmdk lowercased item values. The maintainer agreed this was wrong; the v1.0.0 release notes (8 Mar 2024) say value is now case sensitive (still trimmed), so check your installed version before relying on case-sensitive ids.

How to describe it to the agent

My palette searches /api/search. Use cmdk with shouldFilter={false}. Keep the query in state from Command.Input's onValueChange, debounce it about 150 ms, cancel stale requests, and render results as Command.Item with a human-readable label as the value and the record id in a separate field used by onSelect. Show Command.Loading while fetching and a Command.Empty that includes the search text via useCommandState. After results change, check that pressing Enter selects the first result; if not, control the value prop.

Mistakes to look for

  • Leaving shouldFilter on, so cmdk hides server results that do not textually match.
  • Using the id as value so users must type the id.
  • No request cancellation, so a slow older response overwrites a newer one.
  • A palette that never shows a loading or empty state.

Limits

These are library behaviours reported in issues, not my own test. Versions differ; check the cmdk version in your lockfile against the issue dates.

Sources

  • cmdk README (dip/cmdk, MIT), read through the GitHub API on 19 Oct 2026. Checked: shouldFilter={false} to disable filtering and sorting, a Command.Loading part to render conditionally while loading asynchronous items, keywords as aliases that can affect rank, useCommandState with the "No results found for" example.
  • Issue 103 (opened 13 Mar 2023, closed 30 Jan 2024), issue 181 (opened 21 Sep 2023, closed 8 Mar 2024), issue 280 (open, checked 2026-11-14) and issue 150 (closed 30 Jan 2024), comments read through the GitHub API. Checked: the maintainer replies quoted in the body, the freeze report, the id-as-value complaint with the keywords answer, the first-item selection report, the lowercasing report. Also release v1.0.0 (keywords added, value case sensitive) and the v0.2.1 release notes (filtering performance).
  • Not checked: that the issues are still reproducible on the current release (v1.1.1 was released 14 Mar 2025), the debounce and request-cancellation advice (general practice, not from cmdk), and the agent prompt. I built nothing and did not run cmdk.

Started from a post by @dip (Dip, cmdk maintainer), packaged by the editor. Original post

Subjects

More in prompting

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# cmdk: how do I make a ⌘K palette that searches my API?
Summary: When a cmdk command palette searches server-side results, set `shouldFilter={false}` and show `Command.Loading`; check for odd-input freezes, missing first-item selection, and searches matching IDs instead of labels.
Copy for agent
get the whatworks thread command-palette-search-api-async-cmdk and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread command-palette-search-api-async-cmdk
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks