Combobox fetch

GitHub

API route helper that parses combobox search parameters and returns typed option results.

Installation

bash
pnpm dlx shadcn@latest add @cs/combobox-fetch

Usage

tsx
import { comboboxFetch } from "@/lib/cs/combobox-fetch"
tsx
export async function GET(request: NextRequest) {
  return comboboxFetch(request, async (search, selected) =>
    countries.filter((country) => country.name.includes(search))
  )
}

API Reference

comboboxFetch

Parses Combobox remote-search parameters and returns a typed ActionResult response from a Next.js route handler.

Parameters

NameTypeDefaultDescription
request *NextRequest--
select *(search: string, selected: TValue[]) => Promise<ComboboxOption<TValue>[]>--

Returns: Promise<NextResponse<ActionResult<ComboboxOption<TValue>[]>>>