Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@bv3/router

BestVue32MIT0.1.5TypeScript support: included

Declarative routing fro Vue3

readme

Coverage License Version

中文文档

Declarative routing for Vue3.

The global version of this lib is about 5.2kb after gzipped. And the only dependencies is history, which only 1.5kb after gzipped. Little smaller than Vue-Router which is about 9.7kb after gzipped.

[!Note:]

This project is still under heavy development, the main API may change (mostly add new API) before we reach the stable version which is 1.0.0. You should decided yourself if using this module in your production project.

Why another Router Library

Vue community already had an official router library, why another one?

The main reasoin is that we think Vue official is far too conservative. Vue3 contain a great composition API which have much more benefits then option API, but in order to be compatible with Vue2, Vue3 keep the option API and also Vue-Router will do the same thing. This bring some limition of using composition API like we have to use object to define component etc.

And we are more interested about using JSX as syntax to develop Vue3 application. The React Router API will is more suitable for JSX then Vue-Router. We also not recommend Vue.use() to merge a plugin, althrough Vue.use() also did add provide location info to the rest of app, it will make people fill like they stil using mixin (Vue-Router actually add app.config.globalProperties.$router to compatible the usage of Vue2).

Documentation

changelog

Version 0.1.5

  • Support keepalive, you can add keepalive={true} on <Route> to specify this route should keepalive. Read more on doc
  • Add test utils to make sure keealive work as expect.
  • peerDependency of vue up to 3.0.8 so render keepalive on ssr will work fine, see [https://github.com/vuejs/vue-next/pull/3259].

Version 0.1.3

  • useRoutes use default basenameEffect as () => ''
  • type accepted as VNode also accept JSX.Element so that it worked in JSX

Version 0.1.2

  • Fix <useBlocker> confirm forever bug
  • Fix the usage of watchEffect, unlike useEffect in React, watchEffect accepe an onInvalidate to perform unbind effet

Version 0.1.1

Version 0.1.0

  • Reduce built files to 5.22kb
  • Move tests out of lib
  • We can switch unit tests from using build output
  • Build process now match with Vue3
  • <Route> support use slots.element as content, this make <Route> used in SFC simpler, since in SFC pass VNode as props is not quite convenience
  • element prop and slot in <Route> support function, it will have better performence in vue3.