useComboboxData - Admin Components

Note: This hook is available since Medusa v2.21.0.

The useComboboxData hook loads paginated and searchable options from the Medusa backend for a Combobox component. The Medusa Admin uses it in forms where the user selects a record, such as a product's collection or a region's countries.

Code
import { useComboboxData } from "@medusajs/dashboard/hooks"

Example#

Pass the hook's returned properties to the Combobox component:

Code
1import { Combobox } from "@medusajs/dashboard/components"2import { useComboboxData } from "@medusajs/dashboard/hooks"3import { sdk } from "../lib/sdk"4
5const CollectionSelect = ({ value, onChange }) => {6  const collections = useComboboxData({7    queryKey: ["product_collections"],8    queryFn: (params) =>9      sdk.admin.productCollection.list(params),10    getOptions: (data) =>11      data.collections.map((collection) => ({12        label: collection.title,13        value: collection.id,14      })),15  })16
17  return (18    <Combobox19      value={value}20      onChange={onChange}21      options={collections.options}22      searchValue={collections.searchValue}23      onSearchValueChange={24        collections.onSearchValueChange25      }26      fetchNextPage={collections.fetchNextPage}27      disabled={collections.disabled}28    />29  )30}

The hook debounces the search value before sending the q query parameter to the Medusa backend, and it loads the next page of options when fetchNextPage is called.

To keep a record that the form already selected in the list, pass its ID to defaultValue or selectedValue. The hook then fetches that record separately and adds it to the beginning of options, even when the current page doesn't include it.


Parameters#

The hook accepts an object with the following properties:

Loading...

Returns#

Along with the following, the hook returns the rest of TanStack Query's useInfiniteQuery result.

Loading...
Was this page helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵