{"id":18761,"library":"rollbar-redux-middleware","title":"rollbar-redux-middleware","description":"Redux middleware that integrates with Rollbar error reporting. Version 0.2.0 is the current stable release. It assumes Flux Standard Action (FSA) actions where errors are indicated by an error: true flag and the payload contains the Error object. It automatically includes the Redux store state with reported errors and provides state sanitization via keypaths or a custom sanitizer function. Additionally, it offers an option to wrap all dispatched actions in a try/catch block. Differentiators: simplifies attaching Redux state to Rollbar errors and offers flexible state redaction compared to manual integration.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/rollbar/rollbar-redux-middleware","tags":["javascript","redux","rollbar","middleware","react"],"install":[{"cmd":"npm install rollbar-redux-middleware","lang":"bash","label":"npm"},{"cmd":"yarn add rollbar-redux-middleware","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollbar-redux-middleware","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for the Rollbar client instance.","package":"rollbar","optional":false},{"reason":"Required peer dependency for Redux middleware.","package":"redux","optional":false}],"imports":[{"note":"Default export is a function. CJS require works but ESM is preferred.","wrong":"const rollbarMiddleware = require('rollbar-redux-middleware');","symbol":"rollbarMiddleware","correct":"import rollbarMiddleware from 'rollbar-redux-middleware';"}],"quickstart":{"code":"import { createStore, applyMiddleware } from 'redux';\nimport rollbar from 'rollbar';\nimport rollbarMiddleware from 'rollbar-redux-middleware';\n\nconst Rollbar = new rollbar({ accessToken: process.env.ROLLBAR_ACCESS_TOKEN ?? '' });\n\nconst initialState = { user: { name: 'Alice' } };\nconst rootReducer = (state = initialState, action) => state;\n\nconst rollbarRedux = rollbarMiddleware(Rollbar, ['user.name']);\n\nconst store = createStore(\n  rootReducer,\n  initialState,\n  applyMiddleware(rollbarRedux)\n);\n\nstore.dispatch({ type: 'TEST' });\nconsole.log('Middleware configured. Errors will be reported to Rollbar.');","lang":"javascript","description":"Shows basic setup: importing rollbar and middleware, creating a Rollbar instance, and applying the middleware with state sanitization keypaths."},"warnings":[{"fix":"Ensure actions conform to FSA pattern (error: true, payload: Error) or set third parameter to true to wrap all actions in try/catch.","message":"Assumes action is a Flux Standard Action with error: true to report errors; other error patterns are ignored unless try/catch wrapping is enabled.","severity":"gotcha","affected_versions":"*"},{"fix":"Provide either an array of strings (keypaths) or a function (stateSanitizer) as the second argument.","message":"The second parameter to rollbarMiddleware can be either an array of keypaths or a function; passing a non-array, non-function will cause unexpected behavior.","severity":"gotcha","affected_versions":"*"},{"fix":"Remember to import and instantiate rollbar separately before passing it to rollbarMiddleware.","message":"The rollbar instance must be passed as the first argument; it is not imported internally.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'0.2.0':14 'action':24,26,73 'addit':64 'assum':21 'attach':80 'automat':44 'block':77 'compar':91 'contain':39 'current':17 'custom':61 'differenti':78 'dispatch':72 'error':11,28,33,41,52,85 'flag':35 'flexibl':88 'flux':22 'fsa':25 'function':63 'includ':45 'indic':30 'integr':8,94 'javascript':95 'keypath':58 'manual':93 'middlewar':4,6,98 'object':42 'offer':66,87 'option':68 'payload':38 'provid':54 'react':99 'redact':90 'redux':3,5,47,81,96 'releas':19 'report':12,51 'rollbar':2,10,84,97 'rollbar-redux-middlewar':1 'sanit':56,62 'simplifi':79 'stabl':18 'standard':23 'state':49,55,82,89 'store':48 'true':34 'try/catch':76 'version':13 'via':57 'wrap':70","created_at":"2026-04-25T07:39:59.553655+00:00","updated_at":"2026-04-25T07:39:59.553655+00:00","problems":[{"fix":"Use `import Rollbar from 'rollbar';` or `const Rollbar = require('rollbar').default;` for CommonJS.","cause":"rollbar package may be imported incorrectly; rollbar v2+ uses default export.","error":"TypeError: rollbar is not a constructor"},{"fix":"Ensure Rollbar is instantiated with an accessToken: `const Rollbar = new rollbar({ accessToken: '...' });`","cause":"The Rollbar instance passed to rollbarMiddleware is not properly configured or undefined.","error":"Cannot read property 'apply' of undefined"},{"fix":"Apply redux-thunk or other async middleware before this middleware in the chain.","cause":"The middleware does not handle async actions like thunks; it expects plain FSA objects.","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":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/rollbar/rollbar-redux-middleware","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/rollbar-redux-middleware","openapi_spec":null,"status_page":null,"smithery":null,"categories":["observability","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}