@pinia/plugin-debounce

Debounce any action in your pinia ๐Ÿ store!
208,070 76
Install
npm install @pinia/plugin-debounce
Latest Version:2.0.0
Vue:3
License:MIT
Last Updated:Oct 21, 2026
Links: GitHub  ·  npm
Maintainer: posva

Debounce any action in your pinia ๐Ÿ store!

This is also a very good example of how to create a pinia plugin and how to type it.

Installation

npm install @pinia/plugin-debounce

You also need to use a debounce function like lodash.debounce or ts-debounce

Usage

import { debounce } from 'ts-debounce'
import { PiniaDebounce } from '@pinia/plugin-debounce'

// Pass the plugin to your application's pinia plugin
pinia.use(PiniaDebounce(debounce))

You can then use a debounce option in your stores:

defineStore('id', {
  actions: {
    someSearch() {
      // ...
    },
    other() {
      // ...
    },
  },
  debounce: {
    // debounce all `someSearch` calls by 300ms
    someSearch: 300,
    // you can pass an array of arguments if your debounce implementation accepts extra arguments
    someSearch: [
      300,
      {
        // options passed to debounce
        isImmediate: true,
      },
    ],
  },
})

For setup stores, options are in a second arugment:

defineStore(
  'id',
  () => {
    // ...the store

    return { someSearch }
  },
  {
    debounce: {
      // debounce all `someSearch` calls by 300ms
      someSearch: 300,
    },
  },
)

Extended TypeScript support

By default, extra arguments passed to your debounce implementation are not typed. This can be changed by extending the Config interface in any of your ts files:

import { debounce } from 'ts-debounce'

declare module '@pinia/plugin-debounce' {
  export interface Config {
    Debounce: typeof debounce
  }
}

License

MIT

Related Packages

pinia-plugin-firestore-sync

Sync your pinia state and firestore document at ease!

442
pinia-plugin-loading

Auto loading data binding plugin for pinia. You don't need to write showLoading...

1,337 12
pinia-plugin-created

create created lifecycle method in your pinia ๐Ÿ store!

284 0
pinia-persistedstate-plugin

A pinia plugin like vuex-persistedstate.

8,546
pinia-plugin-router

A pinia plugin that help use vue-router in pinia

4,356

Version History

Version Released License
2.0.0 MIT
1.0.1 MIT
1.0.0 MIT
0.1.0 MIT
0.0.2 MIT