pickstack

Preact + Plausible

Lightweight, cookie-free analytics with Plausible; it counts client-side navigations itself. This page shows exactly what pickstack adds to a Preact project for Plausible: the packages, the new files and the changes to existing ones. Every combination is installed, built, linted and tested in CI.

$ npm create pickstack@latest my-app -- --framework preact --modules plausible --yes
Customize in the configurator

Packages it adds

PackageVersionType
@plausible-analytics/tracker^0.4.7runtime

New files

.env.example
VITE_PLAUSIBLE_DOMAIN=
src/analytics.ts
import { init } from "@plausible-analytics/tracker";

/** Plausible; off until the site's domain is set (see .env.example). Call it once. */
export function initAnalytics() {
  const domain = import.meta.env.VITE_PLAUSIBLE_DOMAIN;
  if (!domain) return;
  init({ domain });
}

Changes to existing files

src/main.tsx (changed)
 import { render } from "preact"; import App from "./App";+import { initAnalytics } from "./analytics"; import "./index.css";  +initAnalytics();+  render(<App />, document.getElementById("app")!);  

Project files

Related templates