Debugging Magic With Vue Devtools - Vue School Articles
Debugging Magic With Vue Devtools - Vue School Articles
Charles Allotey
August 1st 2023
As your Vue.js application grows in size and complexity, errors can become
more complex and challenging to diagnose. That's where Vue Devtools comes
in - a powerful debugging tool that will help you diagnose your code faster and
more effectively. Sign Up for Early Bird
In this article, we're excited to share with you the power of Vue Devtools, a
treasure trove of debugging capabilities that will transform you from a mere
Vue.js coder to a fearless bug-busting hero! So let's get started! 😊
On Mozilla Firefox
Sign Up for Early Bird
On Microsoft Edge
vue-devtools
Then add this code to the `` section of your application HTML file:
<script src="<http://localhost:8098>"></script>
<script>
window.__VUE_DEVTOOLS_HOST__ = '<your-local-ip>' // defa
window.__VUE_DEVTOOLS_PORT__ = '<devtools-port>' // defa
</script><script src="http://<your-local-ip>:8098"></scrip
yarn dev
#or
yarn serve
Step 1 - in your Vue.js application local setup. Right click and navigate to the
inspect option. You can also use the F12 key as a shortcut.
Step 2 - Select the more option to expand the tabs and select the Vue option.
Awesome progress 🚀 now we have our Vue Devtools setup and running
alongside our project. Now we can begin exploring its usage.
Debugging Components
Vue Devtools provides a variety of useful tools to help you understand your
components. One of the most important features is the Component Tree view.
For instance, the App component is the root component and has a child
component called HelloWorld . If you expand the HelloWorld node, you
can see additional details such as its props, data, and computed properties.
Furthermore, the Component Tree view allows you to interact with your
components in real-time. For example, you can click on a component node to
select it, and then view and modify its properties and data in the DevTools
panel.
That’s normal, but we can go through these stages faster and easier with Vue
Devtools.
Firstly in the component tree we can monitor our states. Any changes to our
data is reflected in Component properties in Vue Devtools and with that we can
track and make real-time changes to our components data.
Secondly we have the timeline inspector. The timeline inspector allows you to
travel through previous versions of your states or events.
Imagine being able to rewind to a particular instance to get the state of that
property at that instance. Awesome.
With the timeline inspector you can diagnose if your component events are
firing as expected.
Sign Up for Early Bird
Monitor routes
When creating a Vue.js Single Page Application (SPA), you can use Vue
DevTools to easily track and debug your routes and navigation flow. The Routing
tab logs route data and history during transitions and also displays all the
application routes and their options.
Debugging your Pinia Stores
Sign Up for Early Bird
As our applications grow bigger and more complex, it can be tough to manage
data within the components. But don't worry, we've got a solution! We can
introduce a central store as a central point where all components can access
our data.
You may have heard or used some state management tools like Vuex and Pinia.
Pinia seems to have gained more popularity lately, so in this document, we'll
take a look at how Vue Devtools can help provide a better debugging experience
for Pinia.
The best part is Pinia hooks into Vue devtools to give you an enhanced
development experience in both Vue 2 and Vue 3.
Vue Devtools provides a dedicated tab for your Pinia stores. Within this tab, you
can conveniently view and monitor your stores, allowing for easy tracking of
their data and state. This feature enhances the development experience, making
it simpler to manage and troubleshoot your stores within your Vue.js
application.
Let’s take an example of using Vue Devtools with a Vue.js application with Pinia.
Sign Up for Early Bird
We created a todo application with a simple create and delete feature. With Vue
devtools we are able to track any mutations to our states and make updates to
our store right inside our browser.
The time travel feature also works with your Pinia stores so you are able to
preview previous versions of your store right in the timeline view.
Conclusion
I hope you enjoyed reading this article on Vue Devtools as it offers valuable
insights into the capabilities of this powerful tool for Vue.js developers.
In future articles, I'll share more knowledge and experiences regarding newer
Vue.js debugging tools like Nuxt Devtools and Vite plugin Vue Devtools. These
tools can further streamline your debugging workflow and provide additional
functionalities for your Vue.js applications. Stay tuned for more informative
content!
Charles Allotey
Charles is a Frontend Developer at Vueschool. Has a passion for building great experiences
and products using Vue.js and Nuxt.
Daniel Kelly
Sign Up for Early Bird
Daniel Kelly
Our goal is to be the number one source of Vue.js knowledge for all skill levels. We
offer the knowledge of our industry leaders through awesome video courses for a
ridiculously low price.
More than 120.000 users have already joined us. You are welcome too!
Products Business Services
Courses Sign Up forRemote
Early Bird
Workshops
Mastering Nuxt
Vue.js Forge
Plans Resources
Affiliate Program
Follow us on Social