Skip to content
WingoUI
ComponentsTemplatesDocsPricingAI agentsBlogChangelogContact
Components
Buttons & Actions
ButtonButton GroupCopy ButtonDelete ButtonTheme ToggleToggleToggle Group
Inputs
Avatar UploadCalendarCheckboxColor PickerComboboxCountry SelectCron PickerCurrency InputDate PickerDate Range PickerDate Time PickerDuration PickerEmail InputEmoji PickerFile UploadFilter BuilderInputInput GroupListboxMasked InputMention InputMonth PickerMulti SelectNumber InputOTP InputPassword InputPhone InputRadio GroupRatingSearch InputSegmented ControlSelectSignature PadSliderSwitchTag InputTextareaTime PickerTimezone SelectTree Select
Forms
Address InputBooking WidgetCSV ImportFieldForm WizardInline EditInvoice line itemsRich Text EditorSchema Builder
Navigation
Back To TopBounce SidebarBreadcrumbCommand MenuGlobal SearchGooey NavHook SidebarNav MenuNav TabsPaginationProximity SidebarScroll ProgressSidebarStepsTable Of ContentsTabsTopbarUser MenuWorkspace Switcher
Overlays
Alert DialogContext MenuDialogDrawerDropdown MenuFamily DrawerHover CardPopoverShare DialogSheetShortcuts DialogTooltipTour
Feedback
AlertBannerCookie ConsentEmoji ReactionEmpty StateNotification BellNotification CenterProgressRoute ProgressSetup ChecklistSkeletonSpinnerToast
Data Display
Approval FlowAvatarBadgeCalendar ViewCode BlockComment ThreadContact cardCountdownDescription ListDiff ViewerFile ListFile managerFolderGanttJSON ViewerKbdLog ViewerMarkdownPresenceSchedulerTagTimelineTree View
Tables & Lists
Audit LogData TableDeal PipelineEditable GridKanbanListMembers tablePermissions MatrixTableTask ListVirtual List
Charts & Stats
Animated CounterArea chartBar chartDonut chartFunnel chartGaugeGitHub ActivityHeatmap calendarLeaderboardLine chartRadar chartRadial barSparklineStat CardTrackerTrend badge
Layout
AccordionApp ShellCardCollapsibleDetail LayoutEntity HeaderPage HeaderScroll AreaSeparatorSettings LayoutSplit ViewToolbar
Media
Audio PlayerCarouselCSV ViewerDOCX EditorDOCX ViewerExcel ViewerFile SystemImage compareImage CropperImage GalleryImage LightboxLocation MapPDF ViewerPowerPoint ViewerQR CodeStep PlayerVideo Player
AI Kit
Agent Status CardChat MessageChat ThreadChat WidgetConversation ListFluid OrbGrid RevealMatrix OrbModel PickerPrompt InputReasoning IndicatorRule BuilderSuggestion ChipsTool Call TimelineUsage MeterVoice InputWorkflow Canvas
Text & Effects
Background PatternGravity LettersMarqueeTerminalText AnimateText Rotate
Mobile
Action SheetBottom Tab BarFABHaptic ButtonHero HeaderInstall PromptLarge Title HeaderNotification BannerOnboarding CarouselPicker WheelPull To RefreshSlide To ConfirmSticky CTA BarSwipe DeckSwipeable Tabs
Commerce
Cart drawerCategory pickerCheckout stepsCoupon inputFavorite buttonFilter panelListing cardListing gridOrder trackerPricePrice rangePricing tableProduct galleryQuantity stepperReviewsSeller card
Marketing Sections
App Download SectionBlog Cards SectionCTA SectionFAQ SectionFeature GridFeature ShowcaseHero SectionIntegrations SectionLogo CloudMarketing FooterMarketing HeaderMarketing SectionNewsletter SectionPricing SectionStats SectionSteps SectionTeam SectionTestimonials SectionTimeline SectionVideo Section
Blocks
Admin Dashboard PageAdmin ShellAI Chat PageAPI Keys PageAutomation Builder PageCheckout PageCRM Contact PageCRM Pipeline PageError PagesInbox PageInvoice PageKPI DashboardListing Detail PageLogin PageMarketplace Home PageMarketplace Search PageMarketplace ShellMobile App HomeOnboarding FlowOrder History PagePost Listing WizardPricing PageProfile PageRegister PageSettings PageUsers Admin Page
Templates
About PageAcademy PageAccessibility PageAffiliate PageAgency PageAI Product PageAppointment Booking PageBlog PageBlog Post PageBug Bounty PageCareers PageChangelog PageCommunity PageCompare PageContact PageCustomer Story PageCustomers PageDemo Booking PageDevelopers PageDocs Home PageDownload PageEnterprise PageEvents PageExperts PageFAQ PageFeature PageGlossary PageHelp Article PageHelp Center PageHome Services PageImpact PageIntegration Detail PageIntegrations PageJob Detail PageLanding PageLaunch PageLegal PageManifesto PagePortfolio PagePress PageProduct Tour PagePromo PageReal Estate PageReferral PageResearch Report PageRestaurant PageRoadmap PageROI Calculator PageSecurity PageSolutions PageStartups PageStatus PageStorefront PageSwitch PageTemplate Gallery PageTravel PageWaitlist PageYear in Review Page
Hooks & Utilities
AI ChatChart kitCommerceDate utilsFile exportFile typesFiltersForm validationHapticsInvoicingMotion presetsNavigationNumber formatRelative timeRomanian locationsSpreadsheetText matchTonesUIProvideruseClipboarduseConsentuseControllableStateuseCooldownuseDebounceuseKeyboardInsetuseLocaleuseLongPressuseMediaControlsuseMediaQueryuseOverflowItemsusePersistedStateuseScrollEdgesuseScrollStateuseSelectionuseShortcutuseStickToBottom
GalleryTheme

Hooks & Utilities

useDebounce

Hooks & Utilities

useDebounce React hook in TypeScript

useCooldownuseKeyboardInset
Live props
Options
delay300ms
leading
maxWaitNo limit
  1. Home
  2. Components
  3. Hooks & Utilities
  4. useDebounce
Free

useDebounce React hook in TypeScript

v1.0.0·Added in 1.0.0

React debounce hooks for values and callbacks: search as you type without sending a request on every keystroke.

Type in the search field and watch the two counters: keystrokes climb on every letter, searches only fire once you pause. Press Enter to search at once (flush). Change the delay, add a leading call or a max wait in the playground and type again.

useDebounce is a free React hook in the React hooks and utilities category, written in TypeScript for React 19. It installs as source with npx wingo-ui@latest add use-debounce.

Add to a project

Requirements: React 19, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup

npx wingo-ui@latest add use-debounce

Usage

Import useDebouncedCallback from @/hooks/use-debounce.

import { useState } from "react"
import { useDebouncedCallback } from "@/hooks/use-debounce"

export function ListingSearch({ onSearch }: { onSearch: (query: string) => void }) {
  const [query, setQuery] = useState("")
  const search = useDebouncedCallback(onSearch, 300)

  return (
    <input
      type="search"
      value={query}
      placeholder="Search listings"
      onChange={(event) => {
        setQuery(event.target.value)
        search(event.target.value)
      }}
      onKeyDown={(event) => event.key === "Enter" && search.flush()}
    />
  )
}

API

  • delaydefault 300
    number

    Quiet time in ms before the call runs. 250 to 400 feels instant for search; 0 runs every call at once.

  • leadingdefault false
    boolean

    Also run the first call of a burst at once (then wait for the quiet period before the next one).

  • maxWaitdefault 0
    number

    Longest a call may wait while calls keep coming, in ms, for live previews that must update now and then. 0 means no limit.

  • useDebouncedCallback
    <A extends unknown[]>(callback: (...args: A) => void, delay?: number, options?: { leading?: boolean; maxWait?: number }) => DebouncedFunction<A>

    A stable function that runs callback with the latest arguments once calls stop for delay ms. It always calls the latest callback, so there is nothing to memoize. Pending calls are dropped on unmount.

Parts

  • DebounceOptions

    type

    The options of useDebouncedCallback: { leading?: boolean; maxWait?: number }.

  • DebouncedFunction

    type

    cancel drops the waiting call (clearing a field), flush runs it now (Enter in a search field), pending tells whether one is waiting. Type: ((...args: A) => void) & { cancel(): void; flush(): void; pending(): boolean }.

  • useDebouncedValue

    hook

    The value, updated only after it stopped changing for delay ms. Handy as a query key: fetch when the debounced query changes. Signature: <T>(value: T, delay?: number) => T.

Examples

Debounced filter

useDebouncedValue drives the list, so the filter runs once you pause typing.

Autosave with maxWait

Saves 800 ms after typing stops, and every 3 seconds during long bursts.

Leading edge

The first click refreshes right away; rapid clicks after it count as one.

Dependencies

No dependencies beyond React.

Files

  • hooks/use-debounce.ts

FAQ

Is the useDebounce hook free?

Yes. The source is free and needs no account: copy it from the Code tab or install it with the CLI.

How do I install useDebounce?

Run npx wingo-ui@latest add use-debounce. With shadcn, run npx shadcn@latest add https://wingo-ui.com/r/use-debounce.json.

See also

Search InputText matchlibuseShortcuthookuseControllableStatehook

Used in

Location MapData TableFilter panelListboxSearch InputCommand MenuGlobal SearchTree View

More React hooks and utilities

useKeyboardInsethookuseLocalehookuseLongPresshookuseMediaControlshookuseMediaQueryhookuseOverflowItemshook
All 36 React hooks and utilities
PrevioususeCooldownNext useKeyboardInset
Keystrokes0
Searches0
  • Type to search. Requests show up here.

useDebouncedCallback(search, 300)