Skip to content

plausibleAnalytics

The plausibleAnalytics registry script. It loads https://plausible.io/js/script.js for the input of the example. Call useScriptPlausibleAnalytics(input, options?) from @hamur/scripts/<library> in a component, or list it under scripts.registry.plausibleAnalytics to load it on every page.

Config keyscripts.registry.plausibleAnalytics
FunctionuseScriptPlausibleAnalytics of @hamur/scripts/<library>
Input keysdomain (required), extensions, apiHost
Default triggerclient
Scripthttps://plausible.io/js/script.js
Hostsplausible.io
Bundleyes: scripts.bundle: ["plausibleAnalytics"]
Collection proxyyes: /_hamur/scripts/p/plausible; flags on by default: none
Consentnone

Example

ts
import { defineConfig } from "hamur";
import scripts from "@hamur/scripts";

export default defineConfig({
  framework: "react",
  modules: [scripts],
  scripts: {
    registry: {
      plausibleAnalytics: { domain: "example.com" },
    },
  },
});

It loads after the app mounted and the first idle callback. List plausibleAnalytics in scripts.bundle and the build serves the file from your origin with a SHA-384 integrity (see Bundling). With the script bundled, its collection requests go to /_hamur/scripts/p/plausible on your origin, which forwards them to https://plausible.io with the privacy flags applied; see The privacy proxy.

Every key is checked when the config loads and again in useScriptPlausibleAnalytics: a wrong value stops the build with a message that starts with scripts.registry.plausibleAnalytics. The registry list is on the registry page, and the shared options are in Scripts.