How to extend VueJS router-link

I couldn't find that info over the internet, so here is how you can create a vue component that extends the router-link component of vue-router :

<script>
import Vue from 'vue'

export default {
  extends: Vue.options.components['router-link'],
}
</script>

Note that you should have already registered vue-router somewhere in your app BEFORE importing that component (so the router-link is present inside the list of global components).

As a reminder, registering vue-router goes like this :

import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter);