[Solved] Router Pinia error: getActivePinia was called with no active Pinia. Did you forget to install pinia

Router Pinia error: getActivePinia was called with no active Pinia. Did you forget to install pinia
Solution:1. First create the store TS file

import { createPinia } from "pinia";
const pinia = createpinia();
export default pinia;
Instead of the kind of form created in main.ts.

2. Import in Mian.ts

// Alternative to the traditional direct import in main.ts
import { createApp } from "vue"
import App from './App.vue'
import pinia from "./store/store"

const app = createApp(App)
app.use(pinia)

3. Using Pinia in router.ts

import { createRouter, createWebHistory } from 'vue-router'
import pinia from '../store/store' 
import { useUser} from "../store/useUser"
const store = useUser(pinia)  // Make sure to pass in pinia here
console.log(store) 
After that, you can use the methods and properties of the store as you like

Read More: