Registry / storage / redux-offline-queue

redux-offline-queue

JSON →
library1.1.2jsnpmunverified

A lightweight Redux middleware for queuing actions when the app is offline and dispatching them once connectivity is restored. Version 1.1.2 provides a simple reducer, middleware, and utilities to mark actions for offline queuing. Designed for React Native, it works with redux-saga by suspending sagas during offline periods. Unlike alternatives like redux-offline, it focuses purely on offline queueing without integrated persistence or network detection, leaving those to be handled by the developer. The library ships TypeScript types and is stable, though low-maintenance.

npm install redux-offline-queue
INSTALL
IMPORT
SIG · REDUX-OFFLINE-QUEU
R
redux-offline-queue
storagejavascriptv1.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

reducer
import { reducer } from 'redux-offline-queue'
import reduxOfflineQueue from 'redux-offline-queue'
Must import the named export 'reducer', not the default.
offlineMiddleware
import { offlineMiddleware } from 'redux-offline-queue'
const offlineMiddleware = require('redux-offline-queue').offlineMiddleware
Works with both ESM and CJS. This import is correct.
markActionsOffline
import { markActionsOffline } from 'redux-offline-queue'
const { markActionsOffline } = require('redux-offline-queue').default
It's a named export, not default. Do not destructure from a default import.
ONLINE, OFFLINE
import { ONLINE, OFFLINE } from 'redux-offline-queue'
import { ONLINE } from 'redux-offline-queue/constants'
These are exported directly from the package root, not from a subpath.
suspendSaga
import { suspendSaga } from 'redux-offline-queue'
import suspendSaga from 'redux-offline-queue'
Named export. For saga support.

Complete setup for redux-offline-queue: reducer, middleware, marking actions offline, and dispatching online/offline events.

import { createStore, combineReducers, applyMiddleware } from 'redux'; import { reducer, offlineMiddleware, markActionsOffline, ONLINE, OFFLINE } from 'redux-offline-queue'; // Step 1: Add reducer const rootReducer = combineReducers({ offline: reducer, app: (state = {}) => state, }); // Step 2: Apply middleware const store = createStore(rootReducer, applyMiddleware(offlineMiddleware())); // Step 3: Mark actions offline const actions = { createBlog: (blog) => ({ type: 'CREATE_BLOG', blog }), }; markActionsOffline(actions, ['createBlog']); // Step 4: Monitor connectivity function onConnectivityChange(isConnected) { store.dispatch({ type: isConnected ? ONLINE : OFFLINE }); } // Simulate online/offline onConnectivityChange(true); store.dispatch(actions.createBlog({ title: 'Hello', content: 'World' })); console.log(store.getState());
Debug
Known issues
gotchaThe offline queue is not persisted automatically; use redux-persist or similar to persist the queue across sessions.
fix
Configure redux-persist to persist the 'offline' key or manually store the queue.
affects: *
gotchaWhen using redux-saga, you must use suspendSaga and consumeActionMiddleware to properly suspend sagas during offline.
fix
Apply middleware in order: offlineMiddleware, suspendSaga(sagaMiddleware), consumeActionMiddleware.
affects: *
breakingThe import paths for ONLINE and OFFLINE constants are from the package root, not a subpath. Some older examples might show a different path.
fix
Import { ONLINE, OFFLINE } directly from 'redux-offline-queue'.
affects: <=1.1.2
deprecatedThe library relies on React Native's NetInfo but does not integrate it natively; you must manually dispatch ONLINE/OFFLINE based on connectivity changes.
fix
Use NetInfo or navigator.onLine to detect connectivity and dispatch accordingly.
affects: *
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'offline')
Missing the reducer or reducer not added under key 'offline'.
fix
Add the reducer to combineReducers: offline: reducer from 'redux-offline-queue'.
Actions not being queued when offline.
Actions not marked with markActionsOffline or OFFLINE not dispatched before action.
fix
Call markActionsOffline(creators, ['actionName']) and dispatch { type: OFFLINE } before dispatching the action.
Redux saga tasks not suspending when offline.
Missing suspendSaga and consumeActionMiddleware middleware.
fix
Apply suspendSaga(sagaMiddleware) and consumeActionMiddleware() in the correct order after offlineMiddleware.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
33 hits · last 30 days
node
31
Resources
redux-offline-queue — npm install redux-offline-queue · libregistry