Nostics
Guide

Dev collector

Forward browser diagnostics from Vite dev to a local log file.

Browser diagnostics normally live in the browser console. The dev collector copies them to a local file during Vite dev, which makes them easy to tail, grep, and share.

There are two pieces:

  • createDevReporter() runs in browser code and sends diagnostics over Vite HMR.
  • nosticsCollector runs in the Vite dev server and writes them to a file.

Browser side

Add the dev reporter next to your normal reporter.

src/diagnostics.ts
import { createConsoleReporter, defineDiagnostics } from 'nostics'
import { createDevReporter } from 'nostics/reporters/dev'

export const diagnostics = defineDiagnostics({
  reporters: [createConsoleReporter(), createDevReporter()],
  codes: {
    NUXT_B2011: {
      why: (p: { src: string, mode: 'client' | 'server' }) => {
        const expected = p.mode === 'client' ? 'server' : 'client'
        return `Plugin "${p.src}" is ${expected}-only but was registered with mode "${p.mode}".`
      },
      fix: (p: { mode: 'client' | 'server' }) => {
        const expected = p.mode === 'client' ? 'server' : 'client'
        return `Rename the file or register it with mode "${expected}".`
      },
    },
  },
})

The console reporter still prints in the browser console. The dev reporter adds the Vite dev-server copy.

Vite side

Add the collector to the app consuming the browser code.

vite.config.ts
import { nosticsCollector } from 'nostics/unplugin/dev-server-collector'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [nosticsCollector.vite()],
})

Start Vite and tail the log:

tail -f .nostics.log | jq .

Each diagnostic is appended as one JSON line.

Options

nosticsCollector.vite({
  logFile: '.app-diagnostics.log',
  debug: true,
  excludeStackFrames: [/\/node_modules\//, /\(node:/],
})
OptionDefaultUse
logFile'.nostics.log'File to append diagnostics to
debug!!process.env.DEBUGLog collector activity in the Vite server
excludeStackFramesundefinedRemove matching stack frames before writing

Vite only

nosticsCollector uses Vite configureServer and server.ws. Other unplugin adapters exist because of the shared plugin shape, but they do nothing for this collector.

Use createFileReporter() directly for server-side Node code. Use createFetchReporter() or your own reporter for production telemetry.

Copyright © 2026