Conversation
✅ Deploy Preview for vue-router ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Important Review skippedToo many files! This PR contains 286 files, which is 186 over the limit of 100. You can disable this status message by setting the
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2603 +/- ##
==========================================
- Coverage 91.27% 85.26% -6.01%
==========================================
Files 46 84 +38
Lines 4181 9774 +5593
Branches 1114 2219 +1105
==========================================
+ Hits 3816 8334 +4518
- Misses 358 1428 +1070
- Partials 7 12 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
They require type: module so they cannot run yet

This merges unplugin-vue-router into vue-router with minimal breaking changes. The goal is to release a v5 that is the closest possible to vue-router 4 to ease migration, then release a v6 that has other breaking changes like ESM only, removed deprecated features, improvements for types, etc
Vue Router 5 Migration Guide
Vue Router 5 merges unplugin-vue-router into the core package.
Migrating from unplugin-vue-router
If you're already using
unplugin-vue-router, migration is straightforward—mostly import changes.1. Update Dependencies
2. Update Imports
Vite plugin:
Data loaders:
Unplugin utilities (for custom integrations):
Types:
Volar plugins:
3. Update tsconfig.json
Remove the old client types reference:
Migration Checklist (unplugin-vue-router)
unplugin-vue-routerdependencyvue-routerto v5unplugin-vue-router/vite→vue-router/viteunplugin-vue-router/data-loaders/*→vue-router/experimentalunplugin-vue-router→vue-router/unpluginunplugin-vue-router/volar/*→vue-router/volar/*unplugin-vue-router/clientfrom tsconfigMigrating from Vue Router 4 (without file-based routing)
1. Add Build Plugin
Vite:
Webpack:
Rollup:
esbuild:
2. Update Routes Import
3. TypeScript Configuration
If using the recommended
dts: 'src/typed-router.d.ts', no changes needed—it's auto-included.Otherwise, add the generated types file to your config:
4. Move Page Components
Components must move to
src/pages/(configurable viaroutesFolder).views/Home.vuepages/index.vue/views/About.vuepages/about.vue/aboutviews/User.vuepages/users/[id].vue/users/:idviews/NotFound.vuepages/[...path].vue/:path(.*)5. Update Route Names
Names are auto-generated from file paths:
src/pages/index.vue'/'src/pages/users/[id].vue'/users/[id]'src/pages/users/[id]/posts.vue'/users/[id]/posts'Update
router.push()calls:To keep custom names, use
definePage(), but it's recommended to let Vue Router manage names automatically for consistency.6. File Naming Conventions
Dynamic routes:
[id]:id[[id]]:id?[...path]:path(.*)[slugs]+:slugs+[[slugs]]+:slugs+Index routes with custom names:
Instead of
index.vue, you can use parentheses to give the file a meaningful name without affecting the route:pages/(home).vue/pages/users/(list).vue/usersThis helps keep your codebase organized with descriptive file names and also allows to group related pages together.
pages/(public)/(home).vue/pages/(public)/about.vue/aboutpages/(admin)/(dashboard).vue/adminMigration Checklist (Vue Router 4)
vue-router@5dts: 'src/typed-router.d.ts'src/pages/vue-router/auto-routesrouter.push({ name: ... })callsdefinePage()where custom names neededHybrid Migration (Keep Manual Routes)
Mix file-based and manual routes:
Troubleshooting
Types not recognized: Restart TS server, check
typed-router.d.tsin tsconfigRoutes not generating: Verify
routesFolderpath, check file extensionsRoute name errors: Use new generated names or add
definePage({ name: 'old-name' })New Exports Reference
vue-routervue-router/vitevue-router/auto-routesvue-router/unpluginvue-router/experimentalvue-router/experimental/pinia-coladaNew Features
Volar Plugins for Enhanced IDE Support
Vue Router 5 includes Volar plugins that provide automatic typing in your IDE. No more passing route names to
useRoute()!Setup in
tsconfig.json:{ "compilerOptions": { // needed for the volar plugin "rootDir": ".", }, "vueCompilerOptions": { "plugins": [ "vue-router/volar/sfc-typed-router", "vue-router/volar/sfc-route-blocks", ], }, "include": ["./typed-router.d.ts"], }What you get:
sfc-typed-router— AutomaticuseRoute()and$routetyping based on the current file:sfc-route-blocks— JSON/YAML validation and autocomplete for<route>blocks:Route Customization
Using
definePage()macroUsing
<route>blockUsing plugin config
Plugin Configuration