Registry / observability / vite-plugin-radar

vite-plugin-radar

JSON →
library0.10.1jsnpmunverified

Vite plugin to inject analytics scripts (Google Analytics, Google Tag Manager, Facebook Pixel, LinkedIn Insight, Yandex Metrica, Baidu Tongji, Microsoft Clarity, PostHog, Plausible, TikTok Pixel, Unbounce, and more) into Vite builds. Current stable version 0.10.1, released January 2025. Supports Vite 2–7 with TypeScript types. Key differentiators: multi-provider support, injection control per environment, custom GTM source, and consent mode configuration. Active development with frequent updates.

npm install vite-plugin-radar
INSTALL
IMPORT
SIG · VITE-PLUGIN-RADAR
V
vite-plugin-radar
observabilityjavascriptv0.10.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

VitePluginRadar
import { VitePluginRadar } from 'vite-plugin-radar'
import VitePluginRadar from 'vite-plugin-radar'
Since v0.10.0, only named export is available. Default export was removed (breaking change).
VitePluginRadar
const { VitePluginRadar } = require('vite-plugin-radar')
import VitePluginRadar from 'vite-plugin-radar'
Works with CommonJS via require, but the package is ESM-first. Use named import.
type VitePluginRadarOptions
import { VitePluginRadar } from 'vite-plugin-radar'; const options: VitePluginRadarOptions = { analytics: { id: 'G-XXXXX' } }
import VitePluginRadar from 'vite-plugin-radar'; const options: VitePluginRadar.Options = {}
Types are exported as part of the module; no separate type import path needed. Options type is inferred from the plugin function parameter.

Shows how to configure VitePluginRadar with Google Analytics, Google Tag Manager (with environment) and Facebook Pixel using environment variables.

// vite.config.js import { VitePluginRadar } from 'vite-plugin-radar'; export default { plugins: [ VitePluginRadar({ analytics: { id: process.env.GA_ID ?? 'G-XXXXX', }, gtm: { id: process.env.GTM_ID ?? 'GTM-XXXXX', environment: { auth: process.env.GTM_AUTH ?? '', preview: process.env.GTM_PREVIEW ?? '', }, }, pixel: { id: process.env.PIXEL_ID ?? '0000000', }, }), ], };
Debug
Known issues
breakingDefault export removed in v0.10.0: use named import { VitePluginRadar } instead.
fix
Change 'import VitePluginRadar from "vite-plugin-radar"' to 'import { VitePluginRadar } from "vite-plugin-radar"'.
affects: >=0.10.0
gotchaScripts are not injected in development mode by default. Use enableDev: true to enable.
fix
Add enableDev: true to the plugin options.
affects: >=0.1.0
gotchaSome analytics providers may have CSP (Content Security Policy) issues if scripts are injected dynamically.
fix
Add 'https://www.googletagmanager.com' and other provider domains to your Content-Security-Policy script-src directive.
affects: >=0.1.0
deprecatedUA-XXXXX (Universal Analytics) identifiers are deprecated and may stop working soon.
fix
Upgrade to G-XXXXX (Google Analytics 4) measurement IDs.
affects: >=0.1.0
gotchaYandex Metrica base link changed in v0.10.1; older versions may use outdated URL.
fix
Update to v0.10.1 or later: 'npm install vite-plugin-radar@latest'.
affects: <0.10.1
gotchaMultiple instances of the same provider (e.g., two analytics IDs) must be passed as an array.
fix
Use analytics: [{ id: 'G-XXXXX' }, { id: 'G-YYYYY' }].
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: VitePluginRadar is not a function
Using deprecated default import after v0.10.0.
fix
Change to named import: import { VitePluginRadar } from 'vite-plugin-radar'.
Cannot find module 'vite-plugin-radar' or its corresponding type declarations.
Package not installed or TypeScript cannot resolve types.
fix
Run 'npm install --save-dev vite-plugin-radar' and ensure tsconfig.json includes 'moduleResolution': 'node' or 'bundler'.
vite-plugin-radar: Script not injected in development.
By default scripts are disabled in dev mode.
fix
Add enableDev: true to plugin options: VitePluginRadar({ enableDev: true, ... })
Uncaught SyntaxError: Unexpected token '<'
Malformed injection due to wrong GTM environment or GTM source URL.
fix
Ensure gtmBase and nsBase are valid HTTPS URLs, and environment.auth and environment.preview are correct.
Upgrade
Version history
0.10.1latest on npm
Audit
Dependencies
viterequiredVite is required as a peer dependency; compatible with versions 2–7.
Agent activity
37 hits · last 30 days
node
32
OpenAI (training)
1
Resources
vite-plugin-radar — npm install vite-plugin-radar · libregistry