logo
  • Guide
  • API
  • Blog
  • English
    • 简体中文
    • English
    • @esmx/core
      Esmx
      App
      RenderContext
      ModuleConfig
      PackConfig
      ManifestJson
      @esmx/router
      Router
      Route
      Route Configuration
      RouterLink
      Navigation Guards
      Dynamic Route Matching
      Nested Routes
      Programmatic Navigation
      Scroll Behavior
      Layer Routing
      MicroApp
      Error Types
      Types Reference
      @esmx/router-vue
      RouterPlugin
      Composables
      Components
      Type Augmentation
      @esmx/router-react
      Micro-App Integration
      Hooks & Context
      Components
      SSR
      App
      @esmx/rspack
      @esmx/rspack-vue
      @esmx/rspack-react

      Last Updated: 4/7/2026, 2:16:07 AM

      Previous pageComponentsNext pageMicro-App Integration

      #Type Augmentation

      #Introduction

      @esmx/router-vue automatically augments Vue's TypeScript types when imported, providing type-safe access to $router and $route in both Vue 2.7+ and Vue 3 components.

      #Vue 2

      When using @esmx/router-vue with Vue 2.7+, the following properties are available on Vue component instances:

      interface Vue {
          readonly $router: Router;
          readonly $route: Route;
      }

      #Vue 3

      When using @esmx/router-vue with Vue 3, the following type augmentations are applied:

      declare module 'vue' {
          interface ComponentCustomProperties {
              readonly $router: Router;
              readonly $route: Route;
          }
      
          interface GlobalComponents {
              RouterLink: typeof RouterLink;
              RouterView: typeof RouterView;
          }
      }

      This provides:

      • this.$router and this.$route in Options API
      • Type-safe global RouterLink and RouterView components in templates