{"id":41853,"library":"redux-handler-middleware","title":"Redux Handler Middleware","description":"Redux middleware that executes custom handlers before and after state updates, useful for navigation redirects. Version 1.0.4 is the latest stable release (no updates since 2017). Key differentiator: declarative handler definitions for specific actions, both pre- and post-update. Lightweight (no dependencies). Similar to redux-saga but simpler for basic side effects. Compatible with Redux >= 3.","status":"maintenance","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/ZachPerkitny/redux-handler-middleware","tags":["javascript","redux","middleware"],"install":[{"cmd":"npm install redux-handler-middleware","lang":"bash","label":"npm"},{"cmd":"yarn add redux-handler-middleware","lang":"bash","label":"yarn"},{"cmd":"pnpm add redux-handler-middleware","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for middleware functionality","package":"redux","optional":false}],"imports":[{"note":"Default export. CommonJS require works as well.","wrong":"const createHandlerMiddleware = require('redux-handler-middleware')","symbol":"createHandlerMiddleware","correct":"import createHandlerMiddleware from 'redux-handler-middleware'"},{"note":"Use 'actions' (array) or 'action' (string) but not both.","wrong":"const handlers = [{ action: 'ACTION_TYPE' }]","symbol":"handlerObjects","correct":"const handlers = [{ actions: ['ACTION_TYPE'], beforeHandler: fn, afterHandler: fn }]"},{"note":"applyMiddleware is part of Redux core, not this library.","wrong":"import { applyMiddleware } from 'redux-handler-middleware'","symbol":"applyMiddleware","correct":"import { applyMiddleware } from 'redux'"}],"quickstart":{"code":"import { createStore, applyMiddleware } from 'redux';\nimport createHandlerMiddleware from 'redux-handler-middleware';\n\nconst reducer = (state = { count: 0 }, action) => {\n  switch (action.type) {\n    case 'INCREMENT':\n      return { count: state.count + 1 };\n    default:\n      return state;\n  }\n};\n\nconst handlerMiddleware = createHandlerMiddleware([\n  {\n    actions: ['INCREMENT'],\n    afterHandler: (store, action) => {\n      console.log('Count after increment:', store.getState().count);\n    }\n  }\n]);\n\nconst store = createStore(reducer, applyMiddleware(handlerMiddleware));\nstore.dispatch({ type: 'INCREMENT' });\n// Logs: 'Count after increment: 1'","lang":"javascript","description":"Shows how to create a handler middleware that logs after an increment action."},"warnings":[{"fix":"Use either 'actions: [TYPE]' or 'action: TYPE', not both properties.","message":"Handler objects must use 'actions' as an array or 'action' as a string, not both.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For async side effects, use redux-thunk or redux-saga.","message":"Async handlers (e.g., API calls) are not supported; handlers are synchronous.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider using redux-saga or middleware chains for modern Redux.","message":"Package has not been updated since 2017; may not work with newer Redux versions.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.4':20 '2017':29 '3':61 'action':37 'basic':55 'compat':58 'custom':8 'declar':32 'definit':34 'depend':46 'differenti':31 'effect':57 'execut':7 'handler':2,9,33 'javascript':62 'key':30 'latest':23 'lightweight':44 'middlewar':3,5,64 'navig':17 'post':42 'post-upd':41 'pre':39 'redirect':18 'redux':1,4,50,60,63 'redux-saga':49 'releas':25 'saga':51 'side':56 'similar':47 'simpler':53 'sinc':28 'specif':36 'stabl':24 'state':13 'updat':14,27,43 'use':15 'version':19","created_at":"2026-06-04T18:54:25.469283+00:00","updated_at":"2026-06-04T18:54:25.469283+00:00","problems":[{"fix":"Ensure each handler object has either 'actions' (array) or 'action' (string) property.","cause":"Handler expects 'actions' as an array or 'action' as a string; providing neither causes iteration error.","error":"TypeError: handler.actions is not iterable"},{"fix":"Use thunk middleware for async actions, or dispatch only plain objects.","cause":"Dispatching a function or promise; handlerMiddleware doesn't handle async actions.","error":"Uncaught Error: Actions must be plain objects. Use custom middleware for async actions."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/ZachPerkitny/redux-handler-middleware#readme","github":"https://github.com/ZachPerkitny/redux-handler-middleware","docs":null,"changelog":null,"pypi":null,"npm":"redux-handler-middleware","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}