Vue 3 Composition API
Plans from $25/month

This lesson is for members. Join us?

Subscribe now and get immediate access to this course, 30 more and all future Vue.js courses!

Using Vue Router with Composition API

In this lesson we learn how to access the Vue Router route and router objects from inside the setup function. Since setup() is called before other component options are resolved the this keyword does not reference the component instance as it does within the Options API. Therefore we can use composables provided by Vue Router to access route and router. This is a common pattern utilized by third party libraries to integrate with the composition API.

Links