Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

478
Views
Can't dispatch Vuex actions in router file (non .vue files) in Vue3 and Vuex 4

I really need help with this. I am not able to dispatch any actions from router index.ts file.

My store index is like this:

import { createStore } from "vuex";
import { actions } from "./actions";
import { getters } from "./getters";
import { mutations } from "./mutations";

// ...other code here for state and types etc...

export const store = createStore<State>({
  state,
  actions,
  getters,
  mutations,
});

Main.ts file has it like:

import {store} from "./store";
const app = createApp(App).use(router).use(store);
// ...other code ...

In router, I have a beforeEach In side before each if I use something like:

import { store } from "../store";
// ...other code...
router.beforeEach((to, from, next) => {
    // ...other code ...
    store.dispatch(ActionTypes.SignIn);
    // ...other code ...
}

I am getting this error [vuex] unknown action type: SignIn

Syntax is all correct I guess as it works in .vue files. Please help, let me know what I am doing wrong here. I have seen some examples for Vue 2 which work but Vue 3 and Vuex 4 not working for me. I can share more details in code if needed. Thanks in advance. If it works for me I will upvote and accept your answer :) If some can try this same scenario locally please let me know with example.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!