BeforeEach guard with vue-router and pinia

I’m having an issue with pinia and vue router which im struggling with just creating a beforeeach guard for authenticated routes my auth store has a getter, isAuthenticated:

export const useAuthStore = defineStore("auth", {
  state: () => ({
user: null,
  }),
//...
  getters: {
isAuthenticated() {
  return !!this.user;
}
  },
});

and the beforeeach guard:

router.beforeEach((to) => {
  const auth = useAuthStore();
  console.log(auth.isAuthenticated);
  if (to.meta.requiresAuth && !auth.isAuthenticated) {
    
    return { name: "login" }
  }
})

I was initially having the problem of pinia not being initialised when I try to access the store, but ive fixed that. instead for some reason when I try to access isAuthenticated in the guard it returns false, even though using vue dev tools I can see that it should return true

image
image

Any ideas? thanks!