Skip to content

Releases: vuejs/router

v5.0.1

30 Jan 10:47
4e8a073

Choose a tag to compare

   🐞 Bug Fixes

Β Β Β Β View changes on GitHub

v5.0.0

29 Jan 17:19
a9b6ea8

Choose a tag to compare

Vue Router 5 is a boring release, it merges unplugin-vue-router into the core package with no breaking changes. The only exception is that the iife build no longer includes @vue/devtools-api because it has been upgraded to v8 and does not expose an IIFE build itself. You can track that change in this issue. See the migration guide for instructions on how to upgrade from unplugin-vue-router to Vue Router 5.

Β Β Β πŸš€ Features

   🐞 Bug Fixes

Β Β Β Β View changes on GitHub

v5.0.0-beta.2

26 Jan 14:26
8349400

Choose a tag to compare

v5.0.0-beta.2 Pre-release
Pre-release

Β Β Β πŸš€ Features

   🐞 Bug Fixes

Β Β Β Β View changes on GitHub

v5.0.0-beta.1

22 Jan 11:45
c9921fe

Choose a tag to compare

v5.0.0-beta.1 Pre-release
Pre-release

   🚨 Breaking Changes

  • experimental: Query params are optional by default Β -Β  by @posva (7f000)

Β Β Β πŸš€ Features

   🐞 Bug Fixes

  • Avoid breaking older browsers support Β -Β  by @posva (c7ba4)
  • Trigger navigation guards when keep-alive component is reactivated for different route Β -Β  by @babu-ch and @posva in #2604 (c7735)
  • Add automatic types for param parsers Β -Β  by @posva (9f1f0)
  • Param parsers when dts is not at root Β -Β  by @posva (b6f00)
Β Β Β Β View changes on GitHub

v5.0.0-beta.0

19 Jan 13:48
fbb0557

Choose a tag to compare

v5.0.0-beta.0 Pre-release
Pre-release

Vue Router 5 merges unplugin-vue-router into the core package. It has no breaking changes itself, so you should be able to upgrade it no matter if you use unplugin-vue-router or Vue Router 4 without file-based routing, and everything should just work. If not, please open an issue!

Note

If you are not using unplugin-vue-router, there are no breaking changes affecting you


Migrating from unplugin-vue-router

If you're already using unplugin-vue-router, migration is mostly import changes.

Migration Checklist (unplugin-vue-router)

This is the TLDR version of the steps below:

  • Remove unplugin-vue-router dependency
  • Update vue-router to v5
  • Change plugin import: unplugin-vue-router/vite β†’ vue-router/vite
  • Change data loader imports: unplugin-vue-router/data-loaders/* β†’ vue-router/experimental
  • Change utility imports: unplugin-vue-router β†’ vue-router/unplugin
  • Change Volar plugins: unplugin-vue-router/volar/* β†’ vue-router/volar/*
  • Remove unplugin-vue-router/client from tsconfig / env.d.ts

1. Update Dependencies

pnpm remove unplugin-vue-router
pnpm update vue-router@5

2. Update Imports

Vite plugin:

// Before
import VueRouter from 'unplugin-vue-router/vite'

// After
import VueRouter from 'vue-router/vite'

Other build tools (Webpack, Rollup, esbuild) import from vue-router/unplugin:

import VueRouter from 'vue-router/unplugin'

VueRouter.webpack({
  /* ... */
})
VueRouter.rollup({
  /* ... */
})
// etc.

Data loaders:

// Before
import { defineBasicLoader } from 'unplugin-vue-router/data-loaders/basic'
import { defineColadaLoader } from 'unplugin-vue-router/data-loaders/pinia-colada'
import { DataLoaderPlugin } from 'unplugin-vue-router/data-loaders'

// After
import { defineBasicLoader, DataLoaderPlugin } from 'vue-router/experimental'
import { defineColadaLoader } from 'vue-router/experimental/pinia-colada'

Unplugin utilities (for custom integrations):

// Before
import {
  VueRouterAutoImports,
  EditableTreeNode,
  createTreeNodeValue,
  createRoutesContext,
  getFileBasedRouteName,
  getPascalCaseRouteName,
} from 'unplugin-vue-router'

// After
import {
  VueRouterAutoImports,
  EditableTreeNode,
  createTreeNodeValue,
  createRoutesContext,
  getFileBasedRouteName,
  getPascalCaseRouteName,
} from 'vue-router/unplugin'

Types:

// Before
import type { Options, EditableTreeNode } from 'unplugin-vue-router'

// After
import type { Options, EditableTreeNode } from 'vue-router/unplugin'

Volar plugins:

// Before (tsconfig.json)
{
  "compilerOptions": {
    // needed for the volar plugin
    "rootDir": "."
  },
  "vueCompilerOptions": {
    "plugins": [
      "unplugin-vue-router/volar/sfc-typed-router",
      "unplugin-vue-router/volar/sfc-route-blocks"
    ]
  }
}

// After
{
  "compilerOptions": {
    // needed for the volar plugin
    "rootDir": "."
  },
  "vueCompilerOptions": {
    "plugins": [
      "vue-router/volar/sfc-typed-router",
      "vue-router/volar/sfc-route-blocks"
    ]
  }
}

These enable automatic typing useRoute() when using file-based routing:

<!-- src/pages/users/[id].vue -->
<script setup lang="ts">
// Before: had to pass route name for typing
const route = useRoute('/users/[id]')

// After: automatically typed based on file location!
const route = useRoute()
route.params.id // βœ… typed as string
</script>

<template>
  <!-- $route is also automatically typed -->
  <p>User ID: {{ $route.params.id }}</p>
</template>

3. Update tsconfig.json

Remove the old client types reference. These were either added to an env.d.ts:

-/// <reference types="unplugin-vue-router/client" />

or to your tsconfig.json:

// Before
{
  "include": ["./typed-router.d.ts", "unplugin-vue-router/client"]
}

// After
{
  "include": ["./typed-router.d.ts"]
}

It's also recommended to remove the ./typed-router.d.ts from your tsconfig.json and place it inside src/, as it's automatically included by most setups:

// vite.config.ts
export default defineConfig({
  plugins: [
    VueRouter({
      dts: 'src/routes.d.ts',
    }),
    Vue(),
  ],
})

This will be the default in a future version.

Β Β Β Β View changes on GitHub

v4.6.4

11 Dec 15:13
47b95ba

Choose a tag to compare

Β Β Β πŸš€ Features

   🐞 Bug Fixes

Β Β Β Β View changes on GitHub

v4.6.3

16 Oct 05:39
61838bf

Choose a tag to compare

Please refer to CHANGELOG.md for details.

v4.6.2

15 Oct 14:32
4dd6544

Choose a tag to compare

Please refer to CHANGELOG.md for details.

v4.6.1

15 Oct 14:22
04a621c

Choose a tag to compare

Please refer to CHANGELOG.md for details.

v4.6.0

14 Oct 09:11
37cc3a5

Choose a tag to compare

Please refer to CHANGELOG.md for details.