Skip to content

kaidjohnson/redux-first-vue-routing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Apr 12, 2022
7aba14c Β· Apr 12, 2022
Apr 12, 2022
Jul 1, 2019
Jul 1, 2019
Jul 1, 2019
Oct 15, 2020
Oct 15, 2020
Jul 1, 2019
Jul 1, 2019
Apr 12, 2022
Dec 9, 2020
Aug 2, 2019
Aug 2, 2019

Repository files navigation

npm version Dependency Status Build Status Test Coverage Maintainability

redux-first-vue-routing

A tiny Vue plugin that connects Vue Router with Redux, an implementation of redux-first-routing.

New to Redux? Start Here

Achieve client-side routing the Redux way:

  • Read location data from the store.
  • Update the location by dispatching navigation actions.
  • Let middleware handle the side-effect of history navigation.

Learn more: An Introduction to the Redux-First Routing Model

Redux-first routing

Installation

npm install redux-first-vue-routing

Usage

import { applyMiddleware, createStore } from 'redux';
import { middleware, reducer } from 'redux-first-vue-routing';
import ReduxFirstVueRouting from 'redux-first-vue-routing';
import Vue from 'vue';
import VueRouter from 'vue-router';

// Create the router instance
const router = new VueRouter({
	...
});

// Create a Redux store, including the router reducer and the middleware.
const store = createStore(rootReducer, {}, applyMiddleware(middleware(router)));

// Install the plugin
Vue.use(ReduxFirstVueRouting, { router, store });