Skip to content

Releases: vuejs/router

v5.0.3

19 Feb 20:07
2b4d612

Choose a tag to compare

   🚨 Breaking Changes

  • experimental:
    • Make miss() throw internally and return never Β -Β  by @posva (077e1)
    • Add reroute() and deprecate NavigationResult Β -Β  by @posva (308db)
    • Remove selectNavigationResult Β -Β  by @posva (9e88a)

Β Β Β πŸš€ Features

  • Support _parent in nested folders Β -Β  by @posva (0a37f)
  • Warn on _parent conflict Β -Β  by @posva (182fe)
  • Set _parent as non matchable by default Β -Β  by @posva (8f91c)
  • Warn on conflicting components for routes Β -Β  by @posva (34ace)
  • Use type module Β -Β  by @posva (dc9ff)
  • Add deprecation warning for next() callback in navigation guards Β -Β  by @posva (797f5)
  • Extract alias from definePage Β -Β  by @posva (835df)
  • Display aliases in logs Β -Β  by @posva (7aa60)
  • Deprecate new NavigationResult(to) in favor of reroute(to) Β -Β  by @posva (382e3)
  • experimental:

   🐞 Bug Fixes

  • Avoid non matchable routes in auto-routes Β -Β  by @posva (48649)
  • Handle quotes in d.ts Β -Β  by @posva (d7764)
  • Avoid route entry in map for _parent Β -Β  by @posva (1dfcc)
  • Handle nested groups Β -Β  by @posva (4a4be)
  • Stable route ordering for group folders with same path Β -Β  by @posva (1db94)
  • Correct route ordering for group nodes with inflated scores Β -Β  by @posva (515f4)
  • Cleanup old route overrides Β -Β  by @posva (b28a7)
  • Remove name from _parent.vue files Β -Β  by @posva (6e8f1)
  • ci:
    • Format sponsor files before change detection Β -Β  by @posva (f68d6)
    • Use manual git commit in update-sponsors Β -Β  by @posva (8ee99)
  • experimental:
    • Resolve TS errors in resolver/router type hierarchy Β -Β  by @posva (a86f1)
  • types:
  • volar:

   🏎 Performance

  • Avoid merging empty object in record Β -Β  by @posva (4213e)
Β Β Β Β View changes on GitHub

v5.0.2

02 Feb 09:26
758f70f

Choose a tag to compare

   🐞 Bug Fixes

Β Β Β Β View changes on GitHub

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.