redux-vue

Vue Redux binding higher order component
1,192 19
Install
npm install redux-vue
Latest Version:0.8.2
License:MIT
Last Updated:Oct 14, 2026
Links: GitHub  ·  npm
Maintainer: nadimtuhin

redux-vue

CI npm npm downloads License: MIT

Redux bindings for Vue 2 — a higher-order component (HOC) that connects Vue components to a Redux store, similar to react-redux's connect().

Vue 2 only. This library targets Vue 2.x. For Vue 3, use Pinia or vuex 4.x.


Install

npm install redux-vue
# or
yarn add redux-vue

Setup

Register the plugin on your root Vue instance so all child components can access the store:

// main.js
import Vue from 'vue';
import { reduxStorePlugin } from 'redux-vue';
import store from './store';
import App from './App';

Vue.use(reduxStorePlugin);

new Vue({
  store,
  render: h => h(App),
});

Usage

connect(mapStateToProps, mapDispatchToProps, [mergeProps])(Component)

Wraps a Vue component and injects store state and dispatch functions as props.

// components/TodoApp.js
import { connect } from 'redux-vue';

const TodoApp = {
  props: {
    todos: { type: Array },
    addTodo: { type: Function },
  },
  render(h) {
    return (
      <div>
        <ul>{this.todos.map(t => <li>{t}</li>)}</ul>
        <button onClick={() => this.addTodo('new item')}>Add</button>
      </div>
    );
  },
};

const mapStateToProps = state => ({ todos: state.todos });

const mapDispatchToProps = dispatch => ({
  addTodo: todo => dispatch({ type: 'ADD_TODO', payload: todo }),
});

export default connect(mapStateToProps, mapDispatchToProps)(TodoApp);

Single-file components

// components/App.js
import { connect } from 'redux-vue';
import Comp from './Comp.vue';

const mapStateToProps = state => ({ count: state.count });
const mapDispatchToProps = dispatch => ({
  increment: () => dispatch({ type: 'INCREMENT' }),
});

export default connect(mapStateToProps, mapDispatchToProps)(Comp);

API

connect([mapStateToProps], [mapDispatchToProps], [mergeProps])(Component)

Argument Type Description
mapStateToProps(state, ownAttrs) Function Maps store state to props. Called on every store update.
mapDispatchToProps(dispatch) Function Maps dispatch calls to props.
mergeProps(stateProps, dispatchProps) Function (optional) Combine or rename keys before they reach the child.

Pass-through props — props not declared in the map functions are forwarded to the wrapped component automatically.

Slots — slot content on the connected wrapper is forwarded to the inner component.

reduxStorePlugin

A Vue plugin. Call Vue.use(reduxStorePlugin) once with store set on the root instance. All descendant components will have this.$store available.


Examples

mergeProps

const mergeProps = (stateProps, dispatchProps) => ({
  fullCount: stateProps.count * 2,
  onAdd: dispatchProps.addTodo,
});

export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(App);

Pass-through props

<!-- nonMappedProp is not in mapStateToProps — it still reaches the wrapped component -->
<ConnectedApp nonMappedProp="Foo" />

Slots

<ConnectedApp>
  <span>This slot content is forwarded to the inner component</span>
</ConnectedApp>

Store example

// store.js
import { createStore } from 'redux';

const initialState = { todos: [] };

const reducer = (state = initialState, action) => {
  switch (action.type) {
    case 'ADD_TODO':
      return { ...state, todos: [...state.todos, action.payload] };
    default:
      return state;
  }
};

export default createStore(reducer);

Development

git clone https://github.com/nadimtuhin/redux-vue.git
cd redux-vue
npm install
npm test

Tests live in src/*.spec.js and use Mocha. See CONTRIBUTING.md for contribution guidelines.


License

MIT © Nadim Tuhin

Related Packages

vue-redux

Vue.js mixins for Redux

1,187 142
redux-zero

A lightweight state container based on Redux

182,348 1,960
nuclear-js

Immutable, reactive Flux architecture. UI Agnostic.

19,527 2,268
immhelper

Fast and lightweight library helps you to update js objects without mutating the...

2,516 17

Version History

Version Released License
0.8.2 MIT
0.8.1 MIT
0.8.0 MIT
0.7.1 MIT
0.7.0 MIT