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-input-debounce

v1.0.8

Published

A React component to debounce input onChange event

Downloads

791

Readme

react input debounce npm version License: MIT GitHub stars

react input debounce provides a simple and efficient React component to debounce the onChange event of a standard HTML input element. This prevents excessive re-renders or API calls while a user is actively typing, improving performance and user experience.

import { DebounceInput } from 'react-input-debounce';
...
<DebounceInput debounceTimeout={500} onChange={...} />

✨ Features

  • Debounced onChange Event: Automatically debounces the onChange event of an input field, triggering your handler only after a specified delay.
  • Configurable Debounce Timeout: Easily customize the debounce delay using the debounceTimeout prop.
  • Standard Input Compatibility: Supports all standard HTML <input> attributes and props.
  • TypeScript Support: Built with TypeScript for a robust and type-safe development experience.

📦 Installation

Install the package using npm or yarn:

npm install react-input-debounce

# or
yarn add react-input-debounce

🚀 Usage

Integrate DebounceInput into your React components just like a regular <input> element. Provide an onChange handler and an optional debounceTimeout (defaults to 100ms).

import React, { ChangeEvent, useState } from 'react';
import { DebounceInput, DebounceInputProps } from 'react-input-debounce';

function MyDebouncedForm() {
  const [searchValue, setSearchValue] = useState('');
  const [debouncedSearchValue, setDebouncedSearchValue] = useState('');
  const [timeout, setTimeout] = useState(500);

  // This handler receives the *debounced* change event
  const handleDebouncedChange = (event: ChangeEvent<HTMLInputElement>) => {
    console.log('Debounced value:', event.target.value);
    setDebouncedSearchValue(event.target.value);
    // You would typically perform an API call or expensive operation here
  };

  // This handler receives the *immediate* change event for display purposes
  const handleImmediateChange = (event: ChangeEvent<HTMLInputElement>) => {
    setSearchValue(event.target.value);
  };

  return (
    <div>
      <h1>Search with Debounce</h1>
      <div>
        <label htmlFor="debounce-timeout">Debounce Timeout (ms): </label>
        <input
          id="debounce-timeout"
          type="number"
          value={timeout}
          onChange={(e) => setTimeout(Number(e.target.value))}
          style={{ marginBottom: '15px' }}
        />
      </div>

      <label htmlFor="search-input">Search Term:</label>
      <DebounceInput
        id="search-input"
        type="text"
        placeholder="Type to search..."
        debounceTimeout={timeout} // Dynamic timeout example
        onChange={handleDebouncedChange}
        // All other standard input props are passed through
        className="my-custom-input"
        style={{ width: '300px', padding: '8px' }}
      />
      
      <p>Immediate input value: **{searchValue}**</p>
      <p>Debounced search value: **{debouncedSearchValue}**</p>
    </div>
  );
}

export default MyDebouncedForm;

Props

The DebounceInput component accepts all standard InputHTMLAttributes<HTMLInputElement> in addition to the following specific prop:

| Prop | Type | Default | Description | | :---------------- | :------- | :------ | :------------------------------------------------------ | | debounceTimeout | number | 100 | The delay in milliseconds before the onChange event is fired. |

🤝 Contributing

Contributions are welcome! Feel free to open issues or pull requests on the GitHub repository.

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.