DEV Community

Cover image for Better DX in Vue apps with Vite Devtools
Jakub Andrzejewski
Jakub Andrzejewski

Posted on • Updated on

Better DX in Vue apps with Vite Devtools

Good Developer Experience (DX) is crucial for the Open Source product to be widely used. There are so many OS alternatives nowadays that users can just switch from one to another in a matter of minutes/hours just to have a better experience of using the software.

Because of that, package/framework authors need to work on the DX and UX improvements all the time to not stay behind the competition. In my opinion, Nuxt framework is an example of a tool that delivers a great Developer Experience thanks to features such as auto imports, DevTools, modules, and many more!

If you are interested in learning more about Developer Experience, check out the my article about it here

In today's article, I would like to dive into a project that I recently discovered - Vue Vite DevTools. This project is a Vite plugin that allows you to have amazing DevTools in your Vue application. It was inspired by Nuxt DevTools so the UI is almost the same.

You can check out the plugin with all the documentation here

Installation

The installation of the plugin is really straightforward. We just need to install the plugin with our favourite package manager (in my case it is yarn):




yarn add --dev vite-plugin-vue-devtools


Enter fullscreen mode Exit fullscreen mode

And then, add it to vite.config.ts file, specifically the plugins section:



import { defineConfig } from 'vite'
import VueDevTools from 'vite-plugin-vue-devtools'

export default defineConfig({
  plugins: [
    VueDevTools(),  // <-- here
    vue(),
  ],
})


Enter fullscreen mode Exit fullscreen mode

And that's it! When you run the application with yarn dev you should see the small button at the bottom of your page that when you click it will expand the dev tools page that will look more or less like the following:

Vue Vite Devtools

Features

Vue Vite Devtools provide several useful data about your application that you can use to have better control over the application. Below, I am listing some of them that I have found the most useful:

Pages

The pages tab shows your current routes and provide a quick way to navigate to them. For dynamic routes, it also provide a form to fill with each params interactively. You can also use the textbox to play and test how each route is matched.

Vue Vite Devtools Pages

Components

Components tab show all the components you are using in your app and hierarchy. You can also select them to see the details of the component (e.g. data,props).

Vue Vite Devtools Components

Assets

Assets tab that shows all your static assets and their information. You can open the asset in the browser or download it.

Vue Vite Devtools Assets

Timeline

Timeline tab has three categories: Performance, Router Navigations, and Pinia. You can switch between them to see the state changes and timelines.

Vue Vite Devtools Timeline

Routes

Routes tab is a feature integrated with Vue Router, allowing you to view the registered routes and their details.

Vue Vite Devtools Routes

Pinia

Pinia tab is a feature integrated with Pinia, allowing you to view the registered modules and their details.

Vue Vite Devtools Pinia

Graph

Graph tab provides a graph view that show the relationship between components.

Vue Vite Devtools Graph

Inspect

Inspect expose the vite-plugin-inspect integration, allowing you to inspect transformation steps of Vite. It can be helpful to understand how each plugin is transforming your code and spot potential issues.

Vue Vite Devtools Inspect

Inspector

You can also use the "Inspector" feature to inspect the DOM tree and see which component is rendering it. Click to go to your editor of the specific line. Making it much easier to make changes, without the requirement of understanding the project structure thoroughly. (This feature is implemented based on the vite-plugin-vue-inspector)

Vue Vite Devtools Inspector

Summary

Yes, there is a lot! Huge kudos to the plugin author for this great addition to the Vue & Vite DX. When I discovered this project, I instantly decided to start using it in my applications and so far, this was a really great decision. Can't wait to see more from the author in the future :)

Make sure to visit the repository https://github.com/webfansplz/vite-plugin-vue-devtools and leave a star for the author ⭐️

Top comments (8)

Collapse
 
thejaredwilcurt profile image
The Jared Wilcurt

It's missing two things that the existing Firefox addon offers:

  1. Vue 2 support
  2. The component inspector doesn't work yet (at least not in Firefox)

Those are both pretty important. The new features it comes with are cool.... but not really things I would use daily.

Collapse
 
jacobandrewsky profile image
Jakub Andrzejewski

I see. These are important for sure. Thanks for mentioning them here! :)

Collapse
 
alvarosabu profile image
Alvaro Saburido

Excellent article as always my friend. I can totally use this for TresJS to offer better DX tools to debug since the Vuedevtools doesnt seem to work with Custom Renderers. Is it extendable?

Collapse
 
jacobandrewsky profile image
Jakub Andrzejewski

Not so sure as I am using it in the default configuration but I am sure that the package author could help with that as he is quite responsive :)

Collapse
 
gabrielgomeso profile image
Gabriel Gomes de Oliveira

Amazing! I'm going to try it

Collapse
 
bhaidar profile image
Bilal Haidar

Hey! I am using Laravel with InertiaJS Vue. For some reason, the button is not showing on the page. Any hints? Thanks

Collapse
 
anchan42 profile image
anchan42

Same problem. Have you found a solution?

Collapse
 
anchan42 profile image
anchan42

Use option appendTo: 'resources/js/app.js' make it work :)