Unplugin Console Log Forwarder

0.0.10 · active · verified Tue Apr 21

Unplugin-console is a cross-bundler JavaScript/TypeScript plugin designed to bridge the gap between browser `console` output and your development server's terminal. It leverages the `unplugin` ecosystem to provide real-time forwarding of `console.log`, `info`, `warn`, and `error` messages from the browser directly to your Node.js terminal. Currently at version `0.0.10`, it is in an early, actively developed stage, suggesting frequent updates and potential iterative improvements. A key differentiator is its AST call-site injection approach, which ensures that browser DevTools maintain accurate source file links for logs, unlike runtime `console` overrides. It integrates seamlessly with Vite via its HMR WebSocket for optimal performance, and offers an HTTP fallback for Webpack, Rspack, and other bundlers. The plugin features robust serialization for complex data types (including circular references, Errors, BigInts), color-coded terminal output, stack trace capture, automatic disabling in production environments, and configurable log level filtering and custom prefixes, making it a powerful debugging aid.

Common errors

Warnings

Install

Imports

Quickstart

This Vite configuration integrates unplugin-console, forwarding all browser console messages (log, info, warn, error) to the dev-server terminal with a custom prefix.

import { defineConfig } from 'vite'
import UnpluginConsole from 'unplugin-console/vite'

export default defineConfig({
  plugins: [
    UnpluginConsole({
      levels: ['log', 'info', 'warn', 'error'],
      prefix: '[Browser Log]'
    }),
  ],
})

view raw JSON →