Skip to content

Install with the CLI

Terminal window
npx @plaintrace/cli init --site <site id> --endpoint https://collect.plaintrace.dev

The CLI finds your framework, shows the change as a diff and asks before writing. By default it pins the current script version with Subresource Integrity (read from <endpoint>/v1/sdk); --latest adds the unpinned /t.js instead. It has no runtime dependencies.

Framework File it edits
Next.js App Router app/layout.* or src/app/layout.* (adds next/script)
Next.js Pages Router pages/_document.* (created if missing)
React Router / Remix app/root.*
SvelteKit src/app.html
Astro the first src/layouts/**/*.astro with a </head>, else src/pages/index.astro
Vite, plain HTML index.html or public/index.html

Nuxt, Gatsby, Angular and anything else get the snippet printed with where to put it; nothing is edited. The CLI also leaves a file alone when the tracker is already there, or when the place to insert it (</head>, </Head> or </body>) is missing or appears more than once.

Option Effect
--site <id> The site id from the dashboard (required)
--endpoint <url> The collector (required)
--dir <path> The project directory (default: the current one)
--dry-run Show the change, write nothing
--yes Do not ask (required when not run in a terminal)
--latest Use the unpinned /t.js

Exit codes: 0 done or nothing to do, 1 needs your input, 2 failed.