Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

485
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda