@esmx/router-vue provides Vue integration for @esmx/router, offering a plugin, composables, and components for seamless routing in Vue 2.7+ and Vue 3 applications. The RouterPlugin is the entry point for registering the router with your Vue application.
const RouterPlugin: {
install(app: unknown): void;
};Vue plugin that registers RouterLink and RouterView as global components and sets up $router and $route properties on Vue instances.
import { createApp } from 'vue';
import { Router } from '@esmx/router';
import { RouterPlugin, useProvideRouter } from '@esmx/router-vue';
const router = new Router({
routes: [
{ path: '/', component: Home },
{ path: '/about', component: About }
]
});
const app = createApp({
setup() {
useProvideRouter(router);
}
});
app.use(RouterPlugin);
app.mount('#app');import Vue from 'vue';
import { Router } from '@esmx/router';
import { RouterPlugin, useProvideRouter } from '@esmx/router-vue';
const router = new Router({
routes: [
{ path: '/', component: Home },
{ path: '/about', component: About }
]
});
Vue.use(RouterPlugin);
new Vue({
setup() {
useProvideRouter(router);
}
}).$mount('#app');When installed, the plugin performs the following:
RouterLink and RouterView become available in all templates without explicit importing$router and $route as reactive properties accessible via this.$router and this.$route in Options APIglobalProperties for Vue 3)