Vue DevTools is an essential browser extension for developing Vue applications. It provides powerful inspection and debugging capabilities.
Installing Vue DevTools
- Chrome: Search "Vue.js devtools" in Chrome Web Store
- Firefox: Search "Vue.js devtools" in Firefox Add-ons
- Edge: Search "Vue.js devtools" in Microsoft Edge Add-ons
After installation, you'll see a new "Vue" tab in your browser's developer tools.
Component Inspector
The component inspector lets you explore your component tree:
Viewing Component Hierarchy
- See all components in a tree structure
- Click any component to inspect it
- View parent-child relationships
Inspecting Component State
For each component, you can see:
- Props: Values passed from parent
- State (refs/reactive): Component's reactive data
- Computed: Computed property values
- Provide/Inject: Provided and injected values
Live Editing
You can edit state directly in DevTools:
- Select a component
- Find the value you want to change
- Click and edit the value
- See your UI update in real-time!
Timeline
The timeline shows events over time:
- Component events: Mount, update, unmount
- User events: Clicks, inputs, etc.
- Performance: Rendering time
Useful Debugging Tips
Console Inspection
Access the selected component in the console:
javascript// After selecting a component in DevTools $vm // The component instance $vm.count // Access refs (auto-unwrapped) $vm.props // Access props
Adding Debug Points
vue<script setup> import { ref, watch } from 'vue' const count = ref(0) // Debug with watch watch(count, (newVal, oldVal) => { console.log(`count changed: ${oldVal} → ${newVal}`) debugger // Pause execution here }) </script>
Template Debugging
vue<template> <!-- Quick debug output --> <pre>{{ JSON.stringify(someData, null, 2) }}</pre> <!-- Conditional debug --> <div v-if="false"> Debug: {{ complexValue }} </div> </template>
Console Utilities
vue<script setup> import { ref, onMounted } from 'vue' const items = ref([]) onMounted(async () => { console.time('fetch items') const response = await fetch('/api/items') items.value = await response.json() console.timeEnd('fetch items') // Shows: "fetch items: 234ms" console.table(items.value) // Nice table format console.group('Item details') items.value.forEach(item => console.log(item)) console.groupEnd() }) </script>
Common Issues and Solutions
"Reactivity Not Working"
vue<script setup> import { ref, reactive } from 'vue' // ❌ Common mistake: losing reactivity const state = reactive({ count: 0 }) let { count } = state // count is now a plain number! count++ // This won't update the UI // ✅ Solution: use toRefs or access directly state.count++ // This works // Or import { toRefs } from 'vue' const { count } = toRefs(state) count.value++ // This works </script>
"Component Not Updating"
vue<script setup> import { ref } from 'vue' const items = ref([{ id: 1, name: 'Item' }]) // ❌ Mutating object property doesn't trigger re-render in some cases items.value[0].name = 'Updated' // Might not work as expected // ✅ Ensure you're triggering reactivity items.value = [...items.value] // Create new array reference // Or use Vue's array methods items.value.splice(0, 1, { ...items.value[0], name: 'Updated' }) </script>
"Event Not Firing"
vue<!-- ❌ Event name mismatch --> <ChildComponent @updateValue="handler" /> <!-- kebab-case --> <!-- In ChildComponent --> emit('update-value') <!-- Different casing! --> <!-- ✅ Be consistent --> <ChildComponent @update-value="handler" /> emit('update-value') <!-- Match! -->
Performance Profiling
Vue DevTools includes a performance tab:
- Click "Timeline" in Vue DevTools
- Enable recording
- Interact with your app
- Stop recording
- Analyze component render times
Look for:
- Components that re-render unnecessarily
- Slow computed properties
- Expensive watchers
Best Practices
- Keep DevTools open during development
- Use descriptive component names for easier debugging
- Log meaningful messages with context
- Use the timeline to understand event sequences
- Profile periodically to catch performance issues early