Registry / observability / vite-plugin-fathom

vite-plugin-fathom

JSON →
library0.1.0jsnpmunverified

A Vite plugin that injects the Fathom analytics script into HTML pages during build. Current stable version is 0.1.0. It is a lightweight, single-purpose plugin with peer dependency on Vite >= 6.0.0. It supports environment variable-based configuration via VITE_FATHOM_ID and advanced Fathom options like forceEU, spa, honorDNT, autoTrack, and ignoreCanonical. Differentiators: minimal setup, TypeScript type definitions included, and automatic script injection without manual template modification.

npm install vite-plugin-fathom
INSTALL
IMPORT
SIG · VITE-PLUGIN-FATHOM
V
vite-plugin-fathom
observabilityjavascriptv0.1.0
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.

default (vitePluginFathom)
import vitePluginFathom from 'vite-plugin-fathom'
import { vitePluginFathom } from 'vite-plugin-fathom'
This package exports a default function, not a named export.
type FathomOptions
import type { FathomOptions } from 'vite-plugin-fathom'
import { FathomOptions } from 'vite-plugin-fathom'
FathomOptions is a TypeScript type, use import type to avoid runtime issues.
plugin call
vitePluginFathom()
new vitePluginFathom()
The default export is a function, not a constructor.

Minimal Vite config integrating the Fathom plugin with environment variable and options.

// vite.config.ts import { defineConfig } from 'vite'; import vitePluginFathom from 'vite-plugin-fathom'; export default defineConfig({ plugins: [ vitePluginFathom(process.env.VITE_FATHOM_ID ?? '', { forceEU: true, spa: 'auto', honorDNT: true, }), ], });
Debug
Known issues
breakingRequires Vite version >= 6.0.0. Older Vite versions will fail to load the plugin.
fix
Upgrade Vite to 6.0.0 or later: npm install vite@^6.0.0
affects: 0.1.0
gotchaEnvironment variable VITE_FATHOM_ID must be set (or pass site ID explicitly) otherwise the plugin will throw.
fix
Set VITE_FATHOM_ID in .env file or pass site ID as first argument.
affects: >=0.1.0
gotchaOptions object is optional; if omitted, defaults to empty object.
fix
Ensure if you need custom options, pass them as second argument.
affects: >=0.1.0
Errors
Common errors & fixes
Error: The Fathom site ID must be provided via the VITE_FATHOM_ID environment variable or as the first argument.
No site ID provided and env var not set.
fix
Set VITE_FATHOM_ID=YOUR_SITE_ID or call vitePluginFathom('YOUR_SITE_ID').
TypeError: vitePluginFathom is not a function
Importing as named export instead of default import.
fix
Use import vitePluginFathom from 'vite-plugin-fathom' instead of destructured import.
Error: Vite 6 is required for this plugin
Vite version below 6.0.0.
fix
Upgrade Vite to version 6 or later using npm install vite@^6.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
31 hits · last 30 days
node
28
OpenAI (training)
1
Resources
vite-plugin-fathom — npm install vite-plugin-fathom · libregistry