Package Exports
- vue-router
- vue-router/dist/vue-router.esm.js
- vue-router/package.json
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vue-router) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
vue-router-next 
Status: Alpha
The current codebase has most of the existing features on Vue Router v3.x and is usable. It supports all the merged RFCs.
Since the library is still unstable and because we want feedback on bugs and missing features, it will probably go through a few breaking changes.
Known issues
Breaking changes compared to vue-router@3.x
mode: 'history'
->history: createWebHistory()
base
option is now passed as the first argument tocreateWebHistory
(and other histories)- Catch all routes (
/*
) must now be defined using a parameter with a custom regex:/:catchAll(.*)
router.match
androuter.resolve
are merged together intorouter.resolve
with a slightly different signaturerouter.getMatchedComponents
is now removed as they can be retrieved fromrouter.currentRoute.value.matched
:router.currentRoute.value.matched .map(record => Object.values(record.components)) .flat()
- If you use a
transition
, you need to wait for the router to be ready before mounting the app:Otherwise there will be an initial transition as if you provided theapp.use(router) // Note: on Server Side, you need to manually push the initial location router.isReady().then(() => app.mount('#app'))
appear
prop totransition
because the router displays its initial location (nothing)
Improvements
These are technically breaking changes but they fix an inconsistent behavior.
- Pushing or resolving a non existent named route throws an error instead of navigating to
/
and displaying nothing. - resolving(
router.resolve
) or pushing (router.push
) a location with missing params no longer warns and produces an invalid URL (/
), but explicitly throws an Error instead. - Empty children
path
does not append a trailing slash (/
) anymore to make it consistent across all routes:- By default no route has a trailing slash but also works with a trailing slash
- Adding
strict: true
to a route record orpathOptions: { strict: true }
to the router options (alongsideroutes
) will disallow an optional trailing slash - Combining the point above with a trailing slash in your routes allows you to enforce a trailing slash in your routes
- To redirect the user to trailing slash routes (or the opposite), you can setup a
beforeEach
navigation guard that ensures the presence of a trailing slash
- Because of the change above, relative children path
redirect
on an empty path are not supported anymore. Use named routes instead:Note this will work if// replace let routes = { path: '/parent', children: [{ path: '', redirect: 'home' }, { path: 'home' }], } // with let routes = { path: '/parent', children: [ { path: '', redirect: { name: 'home' } }, { path: 'home', name: 'home' }, ], }
path
was/parent/
as the relative locationhome
to/parent/
is indeed/parent/home
but the relative location ofhome
to/parent
is/home
Missing features
KeepAlive
is only partially supported. Namely, the context (this
) is not working properly- Partial support of per-component navigation guards.
beforeRouteEnter
doesn't invoke its callback
Contributing
See Contributing Guide.