Vue Router Integration & Advanced Usage
Vue Router Integration
Enable route context to automatically tag every log entry with the Vue Router route path that was active when the request was made. This makes it easy to trace which page triggered a slow request or an error without manually correlating by timestamp.
Vue 3 SPA
// main.ts
import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import NetworkDashboard from 'vue-network-dashboard'
import App from './App.vue'
const router = createRouter({ history: createWebHistory(), routes })
const app = createApp(App)
app.use(router)
app.use(NetworkDashboard, {
router,
enrichWithRoute: true,
})
app.mount('#app')Nuxt 3
// plugins/network-dashboard.client.ts
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(NetworkDashboardPlugin, {
router: nuxtApp.$router,
enrichWithRoute: true,
})
})What it adds
When enrichWithRoute: true is configured, each UnifiedLogEntry gains a route field:
entry.route // e.g. "/dashboard/users/42"In the debugger UI:
- A Route filter input appears in the filter bar (only when at least one log carries a route). Supports
regex:prefix. - The Meta tab of each expanded log entry shows a highlighted Route chip.
- The Export modal counts are route-aware — filtering by route reduces the exported set.
The feature has no runtime dependency on vue-router — the plugin accepts any object that satisfies the minimal RouterInstance interface (currentRoute + afterEach).
Advanced Usage
Filtering Logs
Use queryLogs for complex, multi-criteria filtering:
const { queryLogs } = useNetworkDashboard()
const slowPosts = queryLogs({
type: 'http',
method: 'POST',
url: /\/api\//,
minDuration: 1000,
})For reactive in-component filtering, use the bundled useLogFilter composable:
import { useLogFilter } from 'vue-network-dashboard'
const { filters, filteredLogs, resetFilters } = useLogFilter()
filters.value.url = 'api/users'
filters.value.type = 'http'
filters.value.hasError = true
// filteredLogs is a computed ref that reacts to both filters and the live log storeSubscribing to New Logs
const { subscribe } = useNetworkDashboard()
const stop = subscribe((entry) => {
if (entry.error.occurred || (entry.http?.status ?? 0) >= 500) {
myMonitoring.capture(entry)
}
})
onUnmounted(stop)Exporting Logs
const dashboard = useNetworkDashboard()
function downloadJson() {
const json = dashboard.export('json')
const blob = new Blob([json], { type: 'application/json' })
const url = URL.createObjectURL(blob)
Object.assign(document.createElement('a'), { href: url, download: 'network-logs.json' }).click()
}
function downloadCsv() {
const csv = dashboard.export('csv')
const blob = new Blob([csv], { type: 'text/csv' })
// ...
}Logs can also be exported directly from the panel UI via the Export button in the header.
Sentry Integration
import * as Sentry from '@sentry/vue'
import { createSentryAdapter } from 'vue-network-dashboard'
app.use(NetworkDashboardPlugin, {
callbacks: createSentryAdapter(Sentry, {
errorStatusThreshold: 500, // send Sentry event for 5xx (default)
includeBodies: false, // omit bodies from breadcrumbs (default)
}),
})Every request becomes a Sentry breadcrumb. HTTP 5xx and network errors are also sent as Sentry events via captureMessage.
OpenTelemetry Integration
import { trace } from '@opentelemetry/api'
import { createOpenTelemetryAdapter } from 'vue-network-dashboard'
const tracer = trace.getTracer('my-app')
app.use(NetworkDashboardPlugin, {
callbacks: createOpenTelemetryAdapter(tracer, {
httpOnly: true, // skip WebSocket/SSE (default)
includeBodySize: true, // add body size attributes (default)
}),
})Creates one OTel span per HTTP request with semantic HTTP attributes (http.request.method, http.response.status_code, url.full, etc.) per semconv 1.23.
Vue DevTools Integration
Adds a Network inspector tab and timeline layer to Vue DevTools (browser extension ≥ 6.5 and vite-plugin-vue-devtools ≥ 7.x). Requires @vue/devtools-api as a peer dependency.
import { setupDevtools } from 'vue-network-dashboard'
import { useNetworkDashboard } from 'vue-network-dashboard'
if (import.meta.env.DEV) {
app.use(NetworkDashboardPlugin)
const dashboard = useNetworkDashboard()
setupDevtools(app, dashboard)
}The inspector shows every log entry as a tree node with full request/response state. The timeline layer records a marker for each completed HTTP request.
Callbacks
React to logs outside of Vue components — useful for integrating with error tracking or analytics:
app.use(NetworkDashboard, {
callbacks: {
onLog(entry) {
analytics.trackEvent('network_request', {
url: entry.url,
method: entry.method,
status: entry.http?.status,
duration: entry.duration,
})
},
onError(err) {
Sentry.captureException(err)
},
onFlush(cleared) {
console.log(`Flushed ${cleared.length} log entries`)
},
},
})