question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Accessing router instance in Vuex store

See original GitHub issue

With the new best practices for SSR implemented into this app, the store and router instances are generated by createStore() and createRouter() respectively. As importing the router instance is no longer as simple as import router from '../router', is it still possible to achieve programmatic router navigation in the Vuex store?

Apologies if this is not the correct place for this question!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

55reactions
yyx990803commented, May 2, 2017

you can pass the router instance as part of the action payload.

16reactions
justin-schroedercommented, Nov 7, 2017

@trajano this is a pretty good alternative approach to at least getting router data in your vuex store: https://github.com/vuejs/vuex-router-sync

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to navigate using vue router from Vuex actions
import router from './router'. and use router.push. Simple like that.
Read more >
How to access this.$router in actions - Vue Forum
Hi, i cant redirect a router from vuex actions this.$router is undefined axios.post(api_url, queryString.stringify(payload),{ headers: { 'Content-Type': ...
Read more >
[SOLVED] Access Vuex store in router.js - Quasar forum
I want to access Vuex store in router.js (not index.js of route where we could use export default function ({ store }) )...
Read more >
89. Accessing the store state data in the router ... - YouTube
89. Accessing the store state data in the router Navigation Guards in Vue router - Vue js 3 | Vue 3.
Read more >
Use Vuex in Vue Router Navigation Guards - Michael Hoffmann
Vue Router allows us to define Navigation Guards. ... If you are using Vuex you probably store the authenticated state in the Vuex...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found