Bot releases are visible (Hide)
Published by github-actions[bot] over 2 years ago
We are excited to announce the release of Vue Router 4.1 with a few new interesting features, better support for Node ESM and no breaking changes.
component
/components
option in routesIt's now possible to completely omit the component
option when defining routes with children. While nested routes are about defining layouts, they are also directly connected to a path
and users often found themselves defining a pass through component that would just render a <RouterView>
component to reuse the path
structure. You can now simplify this to:
- import { RouterView } from 'vue-router'
- import { h } from 'vue'
-
const routes = [
{
path: '/admin',
- component: () => h(RouterView),
children: [
{ path: 'users', component: AdminUserList },
{ path: 'users/:id', component: AdminUserDetails },
],
},
]
In other words, you can now nest paths without having to define a component.
Passing History State through router.push()
has been implemented and used by the router since its version 4.0 but hasn't been exposed as a public API until now. This enables passing a state
property when calling router.push()
or router.replace()
. This is useful to pass global state to be associated with the history entry that cannot be shared by copying the URL. One common example of this are Modals:
// go to /users/24 but show a modal instead
router.push({ name: 'UserDetail', params: { id: 24 } state: { backgroundView: ... } })
To see a full example, check the modal e2e test, it has been updated to use the state
property.
It's worth noting this shouldn't be used to pass fetched data or complex objects such as classes because of type and size limitations. Check the History State documentation for more information about the state
property.
Given the nature of the <RouterView>
's route
prop, there is also a new function loadRouteLocation()
that can be used on a resolved route location to load a route with lazy loading:
import { loadRouteLocation } from 'vue-router'
const loadedRoute = await loadRouteLocation(router.resolve('/users/24'))
In v4.1 we were initially planning to introduce types to automatically detect the params from a path
property, creating autocomplete and type safety in router.push()
and <RouterLink>
's to
prop. It was implemented but also turned out to be extremely slow after ~50 routes due to the nature of the types relying on nesting and complex unions. Instead, we are introducing a build plugin to generate the types of the routes for you based your file structure. This is similar to Nuxt and Vite Plugin Pages but with full type support (similar to nuxt-typed-router) while allowing you to keep using the exact same API, just with Autocompletion and typing hints 😄. The plugin currently supports Vite, Webpack (with some caveats), and rollup and it's currently experimental to gather feedback from the community and build a flexible solution. We hope to release a stable version in the following months.
Check out the plugin GitHub repository for installation instructions and documentation.
Here are some other examples of how much this plugin can improves your developer experience:
We now expose a few extra entry points for Node but kept the old ones as well to prevent any disruption to the existing users. You can find more information about this in the corresponding pull request.
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] over 2 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] over 2 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] over 2 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] over 2 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] about 3 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] about 3 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] over 3 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] over 3 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] over 3 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] over 3 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] over 3 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] over 3 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] over 3 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] almost 4 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] almost 4 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] almost 4 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] almost 4 years ago
Today Vue Router 4 is officially released as stable.
After 14 alphas, 13 betas and 6 release candidates, Vue Router v4 is ready to bring the best of routing to your Vue 3 applications with improved bundle size, TypeScript integration, new features and consistency improvements for modern apps.
It has taken almost 2 years of work, around 1500 commits, 15 RFCs, and the help of many users and their bug reports and feature requests to get here. Thank you all for your very much appreciated help!
Vue Router is now divided in three modules:
/users/:id
and its rankingOne the most wanted features on Vue Router is Dynamic Routing. It makes the router more flexible and powerful and open possibilities for applications that were not possible before! This is possible thanks to an advanced path parsing with automatic ranking, allowing the router to guess what route should be matched based on the URL string representation, allowing user to define routes in any order.
The new navigation system is more consistent and improves the experience of Scroll Behavior to match native browser behavior. It also gives users almost more information about the status of a navigation and allow using that information to improve user experience through global UI elements like progress bars and modals.
Thanks to the new Vue Devtools, Vue Router is able to create more advanced integrations: navigation in the timeline and a complete route directory that helps you debug routes.
Say good bye to next
and avoid easy-to-make mistakes inside navigation guards: return any value you were passing to next
. The previous version is still supported to ease migration!
More information on the updated documentation.
Encoding has been adapted to make it consistent across different browsers and route location properties (params
, query
and hash
). You don't need to encode these properties when passing them to router.push()
and they will always appear decoded in the route locations (e.g. $route
and useRoute()
).
Vue Router 4 focus on improving the existing Router while keeping a very similar API, migration should be short and almost limited to a few renames if you were using the basics of Vue Router. You can check the full migration guide on the documentation
Vue Router has been effectively stable for the past couple of months and makes it possible to now focus on:
If you want to give Vue Router 4 a quick try, you can check this CodeSandbox, this Vite template with Tailwind CSS, or use the CLI to get started.
To Learn more about Vue Router 4, check out our new documentation. If you are an existing Vue 2.x user, go directly to the Migration Guide.
If your company uses Vue Router, please consider supporting its development by supporting me 🙏 . It will mean a lot and really help me to keep working on improving the Vue Ecosystem.
If you were already using the release candidate version of vue router, you can find the list of improvements on the CHANGELOG.md.
Published by github-actions[bot] almost 4 years ago
Please refer to CHANGELOG.md for details.
Published by github-actions[bot] almost 4 years ago
Please refer to CHANGELOG.md for details.