tell me the best way to add a router to a vue app with vuejs 3?

You need install vue-router like this for vue3:

npm install [email protected] --save


import { createApp } from 'vue'
import App from './App.vue'
    import { createRouter, createWebHistory } from "vue-router"
    const routeInfos = [
            path : "/",
            component : HomePage
            path : "/favorites",
            component : FavoritesPage
    const router = createRouter({
        history : createWebHistory(),
        routes : routeInfos
    export default router;

import In Main.js

import router from "./router"

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top