Skip to content

You are reading the documentation for version 0.6, which is not the latest release.

Server-side rendering (SSR)

$debug is available inside server-rendered code — route guards, store reducers, page setup, server middleware. The plugin installs the global on both sides:

  • Browser — runtime injected via transformIndexHtml; logs to console.{error|warn|info|debug|log|trace} plus forwarded over the Vite WebSocket to the dev terminal.
  • Server — a Node runtime is auto-injected into every SSR-transformed module that references $debug (via the virtual module virtual:mt-debug/ssr). It writes ANSI-colored output directly to process.stdout. As a fallback for same-process SSR setups, the plugin also installs $debug on the Vite dev server's globalThis from configureServer.

In production builds (vite build, including SSR builds), every call site is stripped to void 0 regardless of side. No SSR runtime ships in the output. See Production behavior.

Manual SSR opt-in

For worker-thread or separate-process SSR runners that don't share globalThis with Vite, import the virtual module from your server entry:

ts
// e.g. src/main.server.ts (Analog) or a Nuxt server plugin
import "virtual:mt-debug/ssr";

The module is idempotent (if (!globalThis[GLOBAL_NAME])) and only loads in dev — strip removes any reference in production.