vue-router-dom

Router for Vue 3 and up
500
Install
npm install vue-router-dom@0.4.3
Latest Version:0.4.3
Older releases:3
License:MIT
Last Updated:Mar 16, 2025
Links: GitHub  ·  npm
Maintainer: patryk_walach

vue-router-dom CircleCI codecov

vue-router-dom is an implementation of react-router for vue 3, providing components and hooks for routing.

Table of contents

Install

npm i vue-router-dom

API

For API documentaiton, please visit React Router API.

Non-standard APIs

install

The install export is a function that registers all the components globally

import { install } from 'vue-router-dom'
import { createApp } from 'vue'
import App from './App.vue'

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

app.mount('#app')

Components

Route
v-slot:element

Element slot can be used over element prop.

If both are present element slot will overwrite element prop.

<!-- App.vue -->
<template>
    <BrowserRouter>
      <Routes>
        <Route path="/">
          <Home />
        </Route>
        <Route path="users">
          <template #element>
            <Users />
          </template>
          <template #default>
            <Route path="/">
              <UsersIndex />
            </Route>
            <Route path=":id">
              <UserProfile />
            </Route>
            <Route path="me">
              <OwnUserProfile />
            </Route>
          </template>
        </Route>
      </Routes>
    </BrowserRouter>
</template>

<!-- Users.vue -->
<template>
  <div>
    <nav>
      <Link to="me">My Profile</Link>
    </nav>

    <Outlet />
  </div>
</template>
HashRouter
StaticRouter

StaticRouter, HashRouter are not implemented yet

Hooks

useInRouterContext

is not implemented since it is easy to check in Vue

export default {
  setup() {
    const locationContext = inject(LOCATION_CONTEXT, null)
    if (locationContext === null) {
      throw new Error('not in router context')
    }
    // ...
  },
}

Related Packages

vuex-composition-api

Make Vuex modules with syntax inspired by @vue/composition-api

629 22
vesium

Core Vue composition hooks for Cesium

4,381 10
@vesium/shared

Shared utilities and type definitions for Vesium

4,282 10
vue-compositions

Collection of Vue Composition Apis

479 1

Version History

Version Released Vue License
0.4.3 >=3.0.0-alpha.0 MIT
0.4.2 ^3.0.0-alpha.0 MIT
0.4.0 ^3.0.0-alpha.0 MIT
0.3.0 ^3.0.0-alpha.0 MIT
0.2.0 ^3.0.0-alpha.0 MIT
Pre-releases (2)
Version Released Vue License
1.0.0-beta.1 >=3.0.0-alpha.0 MIT
1.0.0-beta.0 >=3.0.0-alpha.0 MIT