Adding Routing to a Vue.js cli 3.0 app

Jim Cooper picture Jim Cooper · May 1, 2018 · Viewed 29.7k times · Source

The new Vue.js 3.0 plugin architecture is nice, but it seems to to be missing a router plugin. If I choose not to install routing when I first create the project (vue create my-project), I'd expect that I could change my mind later and add routing with something like vue add @vue/router, but that plugin doesn't appear to exist. Is there a way to add routing from the CLI after the fact?

Answer

Isaac Obella picture Isaac Obella · Jun 19, 2018

After some experimenting with vue-cli3, i found that you can use vue add to setup components you missed.

Use vue add router That set up the routing and created some sample components Home and About.

This also work for other modules like adding vuetify with vue add vuetify. You can read more about vue add from the plugins and presets guide