Preact + Umami
Simple, open-source analytics with Umami (Umami Cloud or your own server). This page shows exactly what pickstack adds to a Preact project for Umami: 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 umami --yesCustomize in the configurator
New files
VITE_UMAMI_WEBSITE_ID= VITE_UMAMI_SCRIPT_URL=https://cloud.umami.is/script.js
/** Umami's tracker script; off until the website ID is set (see .env.example). */
export function initAnalytics() {
const websiteId = import.meta.env.VITE_UMAMI_WEBSITE_ID;
const src = import.meta.env.VITE_UMAMI_SCRIPT_URL;
if (!websiteId || !src) return;
const script = document.createElement("script");
script.defer = true;
script.src = src;
script.dataset.websiteId = websiteId;
document.head.append(script);
}
Changes to existing files
import { render } from "preact"; import App from "./App";+import { initAnalytics } from "./analytics"; import "./index.css"; +initAnalytics();+ render(<App />, document.getElementById("app")!);
Project files
.env.example.gitignoreREADME.mdindex.htmlpackage.jsonsrc/App.tsxsrc/analytics.tssrc/components/Counter.tsxsrc/index.csssrc/main.tsxtsconfig.app.jsontsconfig.jsontsconfig.node.jsonvite.config.ts