Registry / http-networking / redux-promise

redux-promise

JSON →
library0.6.0jsnpmunverified

FSA-compliant promise middleware for Redux (v0.6.0). It intercepts actions with a promise as the payload or the action itself as a promise. When the promise resolves, it dispatches a copy of the action with the resolved value and status 'success'; on rejection, it dispatches with the rejected value and status 'error'. The middleware returns a promise to the caller, useful for server-side rendering. It is part of the redux-utilities suite and works seamlessly with redux-actions. Built on the Flux Standard Action (FSA) spec, it requires actions to have a 'type' and optionally 'payload', 'error', and 'meta'. Compatible with all Redux versions. Stable, rarely updated, no known breaking changes since initial release.

npm install redux-promise
INSTALL
IMPORT
SIG · REDUX-PROMISE
R
redux-promise
http-networkingjavascriptv0.6.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

promiseMiddleware
import promiseMiddleware from 'redux-promise'
const { promiseMiddleware } = require('redux-promise')
Default export is the middleware function; named import not available. CommonJS require returns the function directly (not an object).
promiseMiddleware (with redux-actions)
import { createAction } from 'redux-actions'; import promiseMiddleware from 'redux-promise'
const { createAction } = require('redux-actions'); const promiseMiddleware = require('redux-promise')
CommonJS works but ensure you assign to a variable, not destructure. redux-actions is optional.
applyMiddleware (Redux)
import { createStore, applyMiddleware } from 'redux'; import promiseMiddleware from 'redux-promise'; const store = createStore(reducer, applyMiddleware(promiseMiddleware))
import promiseMiddleware from 'redux-promise'; const store = createStore(reducer, promiseMiddleware)
Must pass middleware via applyMiddleware; direct passing will break store creation.

Demonstrates setup of Redux store with promiseMiddleware, a reducer handling the resolved action, and dispatching an async action with a promise payload.

import { createStore, applyMiddleware } from 'redux'; import promiseMiddleware from 'redux-promise'; const reducer = (state = {}, action) => { switch (action.type) { case 'FETCH_USER_SUCCESS': return { ...state, user: action.payload }; default: return state; } }; const store = createStore( reducer, applyMiddleware(promiseMiddleware) ); // Action creator returning FSA action with promise payload const fetchUser = (id) => ({ type: 'FETCH_USER', payload: fetch(`https://reqres.in/api/users/${id}`).then(res => res.json()) }); store.dispatch(fetchUser(1)).then(() => { console.log(store.getState()); // { user: { id: 1, ... } } });
Debug
Known issues
gotchaMiddleware only dispatches on promise resolution, not on rejection unless the action has an error flag.
fix
For rejection handling, ensure the action payload is a promise and the action does not have 'error: true' initially (middleware sets it). Use try-catch in createAction or handle errors in reducer via 'status: error'.
affects: >=0.1.0
gotchaMiddleware returns the original promise; if other middleware do not return next() result, the promise chain may break.
fix
Ensure all previous middleware in the chain return the value of next(action) (or next(action) itself) to propagate the promise.
affects: >=0.4.0
breakingIn v0.6.0, the middleware no longer dispatches the initial action for promise payloads; only success/error.
fix
If you relied on the initial dispatch (e.g., for loading state), add a separate loading action before the promise action.
affects: >=0.6.0
deprecatedThe library is no longer actively maintained; last release 2019.
fix
Consider migrating to Redux Toolkit's createAsyncThunk or RTK Query for better async handling and TypeScript support.
affects: >=0.5.0
Errors
Common errors & fixes
Uncaught Error: Actions must be plain objects. Use custom middleware for async actions.
The middleware is not applied or the promise action is dispatched before applyMiddleware is used.
fix
Ensure you pass the middleware to createStore via applyMiddleware: createStore(reducer, applyMiddleware(promiseMiddleware))
TypeError: Cannot read property 'then' of undefined
Action payload is not a promise or the action is malformed (missing type or payload is not a promise).
fix
Verify your action creator returns an object with 'type' and 'payload' set to a thenable (promise).
Actions must be plain objects. Use custom middleware for async actions.
A non-FSA action (e.g., direct promise) was dispatched without wrapping in an FSA action.
fix
Either dispatch an action with promise payload, or use a different middleware like redux-thunk for direct promise dispatching.
Upgrade
Version history
0.6.0latest on npm
Audit
Dependencies
reduxrequiredPeer dependency; designed to be used with Redux store
flux-standard-actionoptionalImplements middleware based on FSA spec; actions must follow FSA shape
Agent activity
4 hits · last 30 days
node
4
Resources
redux-promise — npm install redux-promise · libregistry