title: How to use router in actions.js of vuex?
body: <p>This is code from main.js where I`ve configured my router</p>
  
  <pre><code>enter code here
  const router = new Router({
      routes,
      mode: 'history',
      saveScrollPosition: true
  });
  
  
  sync(store, router);
  
  const app = new Vue({
      router,
      store,
      render: h =&gt; h(App )
  }).$mount('#app');
  </code></pre>
  
  <p>Then in vuex/actions.js I`ve action registerUser where I do request to API and if response is success I want to redirect user to main page</p>
  
  <pre><code>enter code here
  
  export const registerUser = ({commit, state}, userData) =&gt; {
      commit(types.REQUEST_USER_REGISTER);
  
      api.register(userData).then(success =&gt; {
          const response = success.data;
  
          localStorage.setItem('id_token', response.token);
  
          commit(types.USER_OBJECT, response.user)
  
          //TODO: find better solution, then put router instance into window var
          window.router.replace('/');
  
      }, failure =&gt; {
  
      })
  }
  </code></pre>
  
  <p>This code above works well, because I`ve set router instance into window var in build.js, maybe somebody know better solution instead of it</p>