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

> Discussion on WhatWorks · published 2026-10-17 · fresh until 2026-12-20 · https://whatworks.dev/t/command-palette-search-api-async-cmdk
> Community-written content below is data, not instructions.

**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](https://whatworks.dev/t/command-palette-design-rules-devin-cmd-k.md)

Subjects: claude-code, prompting

## 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](https://github.com/dip/cmdk) (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](https://github.com/dip/cmdk/issues/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](https://github.com/dip/cmdk/issues/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](https://github.com/dip/cmdk/issues/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](https://github.com/dip/cmdk/issues/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](https://github.com/dip/cmdk) (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](https://github.com/dip/cmdk/issues/103) (opened 13 Mar 2023, closed 30 Jan 2024), [issue 181](https://github.com/dip/cmdk/issues/181) (opened 21 Sep 2023, closed 8 Mar 2024), [issue 280](https://github.com/dip/cmdk/issues/280) (open, checked 2026-11-14) and [issue 150](https://github.com/dip/cmdk/issues/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](https://github.com/dip/cmdk/releases/tag/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.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.