{"id":22799,"library":"vite-plugin-radar","title":"vite-plugin-radar","description":"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.","status":"active","version":"0.10.1","language":"javascript","source_language":"en","source_url":"https://github.com/stafyniaksacha/vite-plugin-radar","tags":["javascript","typescript"],"install":[{"cmd":"npm install vite-plugin-radar","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-radar","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-radar","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Vite is required as a peer dependency; compatible with versions 2–7.","package":"vite","optional":false}],"imports":[{"note":"Since v0.10.0, only named export is available. Default export was removed (breaking change).","wrong":"import VitePluginRadar from 'vite-plugin-radar'","symbol":"VitePluginRadar","correct":"import { VitePluginRadar } from 'vite-plugin-radar'"},{"note":"Works with CommonJS via require, but the package is ESM-first. Use named import.","wrong":"import VitePluginRadar from 'vite-plugin-radar'","symbol":"VitePluginRadar","correct":"const { VitePluginRadar } = require('vite-plugin-radar')"},{"note":"Types are exported as part of the module; no separate type import path needed. Options type is inferred from the plugin function parameter.","wrong":"import VitePluginRadar from 'vite-plugin-radar';\nconst options: VitePluginRadar.Options = {}","symbol":"type VitePluginRadarOptions","correct":"import { VitePluginRadar } from 'vite-plugin-radar';\nconst options: VitePluginRadarOptions = { analytics: { id: 'G-XXXXX' } }"}],"quickstart":{"code":"// vite.config.js\nimport { VitePluginRadar } from 'vite-plugin-radar';\nexport default {\n  plugins: [\n    VitePluginRadar({\n      analytics: {\n        id: process.env.GA_ID ?? 'G-XXXXX',\n      },\n      gtm: {\n        id: process.env.GTM_ID ?? 'GTM-XXXXX',\n        environment: {\n          auth: process.env.GTM_AUTH ?? '',\n          preview: process.env.GTM_PREVIEW ?? '',\n        },\n      },\n      pixel: {\n        id: process.env.PIXEL_ID ?? '0000000',\n      },\n    }),\n  ],\n};","lang":"typescript","description":"Shows how to configure VitePluginRadar with Google Analytics, Google Tag Manager (with environment) and Facebook Pixel using environment variables."},"warnings":[{"fix":"Change 'import VitePluginRadar from \"vite-plugin-radar\"' to 'import { VitePluginRadar } from \"vite-plugin-radar\"'.","message":"Default export removed in v0.10.0: use named import { VitePluginRadar } instead.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Add enableDev: true to the plugin options.","message":"Scripts are not injected in development mode by default. Use enableDev: true to enable.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Add 'https://www.googletagmanager.com' and other provider domains to your Content-Security-Policy script-src directive.","message":"Some analytics providers may have CSP (Content Security Policy) issues if scripts are injected dynamically.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Upgrade to G-XXXXX (Google Analytics 4) measurement IDs.","message":"UA-XXXXX (Universal Analytics) identifiers are deprecated and may stop working soon.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Update to v0.10.1 or later: 'npm install vite-plugin-radar@latest'.","message":"Yandex Metrica base link changed in v0.10.1; older versions may use outdated URL.","severity":"gotcha","affected_versions":"<0.10.1"},{"fix":"Use analytics: [{ id: 'G-XXXXX' }, { id: 'G-YYYYY' }].","message":"Multiple instances of the same provider (e.g., two analytics IDs) must be passed as an array.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change to named import: import { VitePluginRadar } from 'vite-plugin-radar'.","cause":"Using deprecated default import after v0.10.0.","error":"TypeError: VitePluginRadar is not a function"},{"fix":"Run 'npm install --save-dev vite-plugin-radar' and ensure tsconfig.json includes 'moduleResolution': 'node' or 'bundler'.","cause":"Package not installed or TypeScript cannot resolve types.","error":"Cannot find module 'vite-plugin-radar' or its corresponding type declarations."},{"fix":"Add enableDev: true to plugin options: VitePluginRadar({ enableDev: true, ... })","cause":"By default scripts are disabled in dev mode.","error":"vite-plugin-radar: Script not injected in development."},{"fix":"Ensure gtmBase and nsBase are valid HTTPS URLs, and environment.auth and environment.preview are correct.","cause":"Malformed injection due to wrong GTM environment or GTM source URL.","error":"Uncaught SyntaxError: Unexpected token '<'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}