We can integrate the router into the store with the official vuex-router-sync package. It will expose the current route in the state (state.route) and will commit a mutation each time the route changes:
- Install it with the usual command:
npm i -S vuex-router-sync
- To use it, we need the sync method in the main main.js file:
import { sync } from 'vuex-router-sync'
sync(store, router)
Now, you can access the state.route object and time-travel debugging will apply to the router as well.