{"id":22547,"library":"vite-console-forward-plugin","title":"Vite Console Forward Plugin","description":"A Vite plugin that forwards browser console logs (console.log, console.warn, console.error, etc.) to the Vite dev server console. v2.0.1 is the latest stable release, requiring Vite ^6.0.0 || ^7.0.0. Released as a single-file TypeScript plugin under MIT. Differentiates from similar tools by being a minimal, no-dependency Vite plugin with configurable endpoints and log levels, and automatic buffering. Useful for debugging in environments where browser dev tools are inaccessible, such as mobile devices or CI pipelines.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/mitsuhiko/vite-console-forward-plugin","tags":["javascript","vite","plugin","console","logging","development","debugging","typescript"],"install":[{"cmd":"npm install vite-console-forward-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add vite-console-forward-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-console-forward-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: requires Vite 6 or 7 to run as a plugin","package":"vite","optional":false}],"imports":[{"note":"The package exports a named function, not a default export. Use named import.","wrong":"import consoleForwardPlugin from 'vite-console-forward-plugin'","symbol":"consoleForwardPlugin","correct":"import { consoleForwardPlugin } from 'vite-console-forward-plugin'"},{"note":"TypeScript users should import the options type for proper typing.","symbol":"ConsoleForwardOptions","correct":"import type { ConsoleForwardOptions } from 'vite-console-forward-plugin'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport { consoleForwardPlugin } from 'vite-console-forward-plugin';\n\nexport default defineConfig({\n  plugins: [\n    consoleForwardPlugin({\n      enabled: process.env.NODE_ENV === 'development',\n      endpoint: '/api/debug/client-logs',\n      levels: ['log', 'warn', 'error', 'info', 'debug']\n    })\n  ],\n  server: {\n    port: 5173\n  }\n});","lang":"typescript","description":"Configures the plugin in vite.config.ts with enabled toggle, custom endpoint, and forwarded log levels."},"warnings":[{"fix":"Use vite-console-forward-plugin@1.0.0 if using Vite 5.","message":"v2.0.0 dropped support for Vite 5. Plugins using Vite 5 must stay on v1.x.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use a unique endpoint path (e.g. '/__console_logs__') to avoid conflicts.","message":"The endpoint must not conflict with other routes in your Vite project, as the plugin adds a middleware that intercepts POST requests to that path.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set `enabled: false` and ensure the plugin is conditionally included only in dev config.","message":"If the plugin is not enabled, no middleware is registered, but the client-side injection still occurs? Check documentation; injection may still happen even if disabled.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"npm install vite-console-forward-plugin --save-dev","cause":"Missing installation; package not in node_modules.","error":"Error: Cannot find module 'vite-console-forward-plugin'"},{"fix":"Use `import { consoleForwardPlugin } from 'vite-console-forward-plugin'`","cause":"Incorrect import style: using default import instead of named import.","error":"TypeError: (0 , vite_console_forward_plugin.consoleForwardPlugin) is not a function"},{"fix":"Either downgrade plugin to v1.0.0 or upgrade Vite to ^6.0.0 || ^7.0.0","cause":"Using Vite 5 or older with v2+ of the plugin.","error":"Error: Vite plugin 'vite-console-forward-plugin' requires Vite >=6.0.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}