0

I want to migrate from vite-plugin-pages to unplugin-vue-router. In router folder of my vue3 project, I've defined the following route config in my route folder based vite-plugin-pages as follows:

**
 * Route configuration
  const router = createRouter({
  history: createWebHistory(),

  routes: [
    // ℹ️ We are redirecting to different pages based on role.
      {
      path: "/",
      redirect: (to) => {
        const isLoggedIn = isUserLoggedIn();

        if (isLoggedIn) {
          return { name: "dashboards-analytics" };
        }

        return { name: "home" };
      },
    },
    ...setupLayouts(routes),
  ],
  scrollBehavior() {
    return { top: 0 };
  },
});

I am seeking to use unplugin-vue-router instead, and implement the above approach in this plugin. How can i do it?

amir tbi
  • 320
  • 2
  • 14

0 Answers0