npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-remote-combo

v1.1.10

Published

Headless remote autocomplete for React with pagination, debounced search, and optional UI.

Readme

react-remote-combo

npm version npm downloads license

Headless-first remote autocomplete for React with debounced search and paginated results.
Use the optional UI component (UiAutocomplete) or stay fully headless with hooks.

Features

  • Remote search with infinite pagination
  • Debounced search input
  • Single and multi-select modes (multiple)
  • Custom rendering: renderOption, renderEmpty, renderLoading, renderError
  • Optional icon slots: loading, clear, check, chevron
  • Style overrides: className, popoverContentClassName, commandListClassName, clearButtonClassName
  • TypeScript-first API and exported types

Installation

npm install react-remote-combo

UI dependencies are optional. Use the headless hook for full control.

Optional UI dependencies (for UiAutocomplete)

npm install @radix-ui/react-popover cmdk

Demo

Try it live: https://codesandbox.io/p/sandbox/gw72f4

Quick Example

Wrap your app with QueryClientProvider before using the component.

import { useState } from 'react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import {
  UiAutocomplete,
  type OptionType,
  type FetchPaginatedPageArgs,
  type PaginatedApiResponse,
} from 'react-remote-combo'

const queryClient = new QueryClient()

function App() {
  const [value, setValue] = useState<OptionType | null>(null)

  const fetchPage = async (
    args: FetchPaginatedPageArgs,
  ): Promise<PaginatedApiResponse<Record<string, unknown>>> => {
    type UserRow = { id: number; name: string; email: string; username: string }

    const res = await fetch('https://jsonplaceholder.typicode.com/users', {
      signal: args.signal,
    })
    const users = (await res.json()) as UserRow[]
    const expandedUsers = Array.from({ length: 10 }, (_, groupIndex) =>
      users.map((user, index) => ({
        ...user,
        id: groupIndex * users.length + index + 1,
        name: `${user.name} ${groupIndex + 1}`,
        email: user.email.replace('@', `+${groupIndex + 1}@`),
        username: `${user.username}${groupIndex + 1}`,
      })),
    ).flat()

    const term = args.searchTerm.trim().toLowerCase()
    const filtered = term
      ? expandedUsers.filter((user) => user.name.toLowerCase().includes(term))
      : expandedUsers
    const start = (args.page - 1) * args.pageSize
    const end = start + args.pageSize
    const pageData = filtered.slice(start, end)
    const lastPage = Math.max(1, Math.ceil(filtered.length / args.pageSize))

    return {
      data: pageData,
      pagination: {
        total: filtered.length,
        current_page: args.page,
        last_page: lastPage,
        per_page: args.pageSize,
      },
    }
  }

  return (
    <QueryClientProvider client={queryClient}>
      <UiAutocomplete
        queryKey={['items']}
        fetchPage={fetchPage}
        value={value}
        onChange={setValue}
        placeholder="Search items..."
        pageSize={10}
      />
    </QueryClientProvider>
  )
}

Multi-select mode:

const [users, setUsers] = useState<OptionType[]>([])

<UiAutocomplete
  multiple
  queryKey={['items']}
  fetchPage={fetchPage}
  value={users}
  onChange={setUsers}
  pageSize={10}
/>

API

UiAutocomplete

Required props:

  • queryKey: readonly unknown[]
  • fetchPage: FetchPaginatedPage<Record<string, unknown>>
  • value: OptionType | null (single) or OptionType[] (multiple)
  • onChange: (value) => void matching the selected mode

Optional props:

  • Data/search: pageSize, searchParam, nameKey, idKey, additionalParams, debounceMs
  • Behavior: multiple, triggerOnFocus (default: true), disabled, clearable
  • Render customization: renderOption, renderEmpty, renderLoading, renderError
  • Label/value mapping: getOptionLabel, getOptionValue
  • Styling: className, popoverContentClassName, commandListClassName, clearButtonClassName
  • Icon slots: icons?: { loading?: ReactNode; clear?: ReactNode; check?: ReactNode; chevron?: ReactNode }

usePaginatedSearch

Thin adapter hook for custom UIs.

Options:

  • queryKey, fetchPage
  • pageSize, searchParam, nameKey, idKey, additionalParams, debounceMs

Returns:

  • options
  • isLoading, isError, error
  • fetchNextPage, hasNextPage, isFetchingNextPage
  • searchTerm, handleSearchChange, refetch

Types

  • OptionType
  • PaginatedApiResponse<T>
  • FetchPaginatedPageArgs
  • FetchPaginatedPage<T>

Custom UI (Headless)

Use usePaginatedSearch when you want full UI control:

const {
  options,
  searchTerm,
  handleSearchChange,
  fetchNextPage,
  hasNextPage,
  isLoading,
  isError,
  error,
} = usePaginatedSearch({
  queryKey: ['users'],
  fetchPage,
})

Links

  • GitHub: https://github.com/elgedawy31/react-remote-combo
  • npm: https://www.npmjs.com/package/react-remote-combo