peepless
Privacy-first analytics for your vibe-coded app. Analytics that doesn't peep.
Peepless counts what you actually want to know (how many people came, where from, which countries, and whether they used the thing) and keeps daily totals only. There's no cookie, no visitor ID and no session. It never stores an IP address, a URL or a user agent. Since there's nothing about any one person to leak, there's no cookie banner to show either.
- Under 2 KB in the browser (gzipped, checked on every build), with no dependencies.
- Real people, not bots. Automated browsers send nothing. Crawlers and
link previewers are dropped on the server. A separate
humancount only includes visits with a real tap, key press or 10 seconds on screen. - Your database, your numbers. The counter is one web-standard handler that runs on Next.js, Vercel, Netlify, Cloudflare, Deno or a Supabase Edge Function. It writes to a single Supabase table, or anywhere you like.
- Works under a strict CSP (
script-src 'self'), which breaks most analytics snippets.
It's for small apps and side projects that want to know "is anyone using
this?". It isn't meant for billing, ad attribution or following a user around.
Counts are best effort: an ad blocker can stop the beacon, and someone who
fakes the Origin header from a script can add counts, up to the rate limit.
Ask your AI to add it
Paste this into Lovable, Bolt, Cursor, Claude Code or similar:
Add privacy-first analytics with the
peeplessnpm package. Follow https://unpkg.com/peepless/llms.txt exactly. My site ishttps://example.com. Count these actions:signed_up,exported.
llms.txt is the whole recipe, written for coding assistants. It
covers which starter to use for your stack, where each file goes, and what not
to change.
Set it up yourself
1. Make the table
In your Supabase project, open the SQL editor and run
starters/supabase/schema.sql. It creates a
peepless.counts table that the public API can't reach. Only your server can
write to it, through the peepless_add function.
2. Add the endpoint
Pick the one that fits your app:
- Next.js (on Vercel or anywhere else): copy
starters/nextjs/app/api/peepless/route.tstoapp/api/peepless/route.ts. Then setSUPABASE_URLandSUPABASE_SERVICE_ROLE_KEYas server-only environment variables. - A Vite or React app on Supabase (Lovable, Bolt): copy
starters/supabase/functions/peepless/index.tstosupabase/functions/peepless/index.ts. Deploy it withsupabase functions deploy peepless --no-verify-jwt. Supabase provides its URL and key automatically. - SvelteKit: copy
starters/sveltekit/src/routes/api/peepless/+server.tsto the same path in your app, with the same two private env vars. - Cloudflare Workers (a site served from Workers static assets), counting
into D1 instead of Supabase: copy
starters/cloudflare/and follow the steps at the top of itssrc/index.ts. It skips step 1: its migration makes the table. - Anything else with web-standard Request/Response (Remix, Astro, Hono,
Deno, Bun): call
createHandler({...})(request)from a POST route at/api/peepless. CI runs the handler on Node, Deno, Bun and Cloudflare's workerd.
Not on Supabase? Any Postgres works (Neon, RDS, your own): run
starters/postgres/0001_peepless.sql
and use postgresStore with whatever runs SQL in your app:
import { postgresStore } from 'peepless/server'
store: postgresStore((text, params) => pool.query(text, params).then((r) => r.rows)), // pg
// postgres.js: postgresStore((text, params) => sql.unsafe(text, params))
// Neon: postgresStore((text, params) => neon(process.env.DATABASE_URL!).query(text, params))
In whichever file you use, list your site's origin and the events it may count:
projects: {
'my-app': { origin: 'https://example.com', events: ['signed_up', 'exported'], routes: ['/', '/blog/*', '/app/*'] },
},
3. Start counting
npm install peepless
import { start, track } from 'peepless'
start({
project: 'my-app',
host: 'example.com', // counts only here: not on localhost or preview URLs. A list works too.
routes: ['/', '/blog/*', '/app/*'], // optional: page types, never the real path
// campaigns: ['newsletter', 'launch'], // optional: ?ref= tags to count; list them in the server's project too
// endpoint: 'https://<ref>.supabase.co/functions/v1/peepless', // with the Edge Function
})
// Later, when someone finishes the thing your app is for:
track('exported')
track('signed_up', user.id) // with a key: at most once per key per page load (the key is never sent)
Call start once, as early as you can, such as in main.tsx or your root
layout's client component. It counts the first page and every client-side
navigation after it. A track that runs before start is held (up to 20)
and sent once start runs, so import order doesn't matter.
Typed events. Give start your event names and track on what it returns
won't compile with a typo. It's types only and adds nothing to the bundle:
export const peepless = start<'signed_up' | 'exported'>({ project: 'my-app', host: 'example.com' })
peepless.track('exportd') // type error
Is it working? Nothing is sent on localhost, so pass debug: true while
developing: each beacon is logged to the console instead of sent, on any host.
What start returns also says whether it's counting, and why not:
const p = start({ project: 'my-app', host: 'example.com' })
p.counting // false on localhost
p.reason // 'not-live', 'automated', 'opted-out', 'no-beacon', 'no-browser' or 'debug'
No bundler? Copy node_modules/peepless/dist/peepless.js into your
public/ folder and load it from your own site:
<script src="/peepless.js" data-project="my-app" data-host="example.com" data-routes="/ /blog/* /app/*" defer></script>
Then call window.peepless.track('exported'). Use data-endpoint if the
endpoint isn't at /api/peepless, list several hosts in data-host
separated by spaces, data-campaigns="newsletter launch" for campaign tags,
data-respect-gpc to honor Global Privacy Control, data-base for an app
that shares its host (below), and data-debug to log instead of sending.
Two apps on one host? A site at example.com/ and a tool at
example.com/tools/x/ can count as two projects: each calls start with its
own project. Give the tool base: '/tools/x/', so someone who clicks through
from the main site counts as a visit to the tool (from example.com, which the
server files as from:direct, the site itself). Without base, only a
referrer on another host makes a visit.
What gets counted
Each count is a +1 on today's (UTC) total for one name:
| Counter | When |
|---|---|
pageview |
Every page, including client-side navigations (see below) |
visit |
The first page of a visit from another site, or from none |
from:<source> |
On a visit: search, ai, reddit, x, linkedin, github, hn, producthunt, bluesky, facebook, youtube, direct or other |
country:<cc> |
On a visit: the visitor's country (country:us), when your host provides it; otherwise country:xx |
page:<pattern> |
The page-type pattern the path matched (page:/blog/*), or page:other |
via:<tag> |
On a visit from a link tagged ?ref=newsletter (or ?utm_source=): the tag, when you list it in campaigns; otherwise via:other |
human |
Once per visit, on the first real tap, click, key press or wheel, or after 10 s on screen |
| your events | Each track() of an event you listed |
The browser sends the project name, the event, and on a visit the referrer's
hostname, the route pattern and, if you list campaigns, the campaign tag (a
tag you didn't list is sent as other, so a referral code never leaves the browser). The server turns these into the counters
above, then forgets them. openapi.yaml describes exactly what
is sent, and docs/counters.md the names that are stored.
What counts as a page view
- The first page, once it's shown (a prerendered page waits until someone sees it).
- A new path through
history.pushState,history.replaceState, or the back and forward buttons. That covers the routers in Next.js, React Router, Vue, SvelteKit and the like. - A page restored from the back/forward cache, as a page view but not a new visit, the same as the full reload it stands in for.
Not a page view: a change to the query string or the #hash alone, or a
pushState to the path you're already on. So an app with a hash router
(/#/settings) counts its first page only.
The country comes from the header your host already sets (x-vercel-ip-country
on Vercel, cf-ipcountry on Cloudflare, cloudfront-viewer-country on AWS).
Peepless never looks up an IP address. Pass country: () => null to
createHandler to count no countries.
Reading your numbers
In a terminal: npx peepless report prints the last 30 days for each
project, from the same SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY the
endpoint uses (it reads .env.local and .env too). Add --project my-app
or --days 7 to narrow it.
Nothing showing up? npx peepless doctor --site https://example.com --project my-app
checks that the table exists, that the key works, and that your endpoint
answers a test beacon (one that counts nothing), and says which failed. Add
--endpoint if yours isn't at /api/peepless.
In your own page: read the counts on your server and let summarize turn
counter names into a report:
import { readCounts, summarize, supabaseStore } from 'peepless/server'
const store = supabaseStore({ url: process.env.SUPABASE_URL!, key: process.env.SUPABASE_SERVICE_ROLE_KEY! })
const rows = await readCounts(store, { project: 'my-app', since: '2026-11-01', until: '2026-11-30' })
const s = summarize(rows, { since: '2026-11-01', until: '2026-11-30' })
// s.visits, s.humans, s.pageviews; s.sources.search, s.countries.de, s.pages['/blog/*'], s.events.exported;
// s.days: [{ day, pageviews, visits, humans }, ...] with zeros for quiet days
Days are UTC. human ÷ visit is the share of visits by real, engaged people.
Search and privacy bots that run JavaScript end up in visit but not in human.
Over HTTP: when the page that shows the numbers lives somewhere without
the database key (another app, a dashboard), serve them with
createStatsHandler and a token of its own. The starters include it:
starters/nextjs/app/api/peepless/stats/route.ts
and starters/supabase/functions/peepless-stats/index.ts.
Set PEEPLESS_STATS_TOKEN to a long random secret (openssl rand -hex 32), then from a server:
curl -H "Authorization: Bearer $PEEPLESS_STATS_TOKEN" "https://example.com/api/peepless/stats?project=my-app"
It answers the same report as JSON for the last 30 days, or &since= and
&until= (UTC days, up to 366 at a time). The token is not the database key
and can only read. Keep it on servers: anyone with it can read your numbers.
openapi.yaml describes the request and the answer.
In SQL:
select counter, sum(count) from peepless.counts
where day > current_date - 30 group by counter order by 2 desc;
What's never counted
The client sends nothing in these cases:
- Off the live site: localhost, preview deployments, or any host but
hostorwww.host. - From automated browsers: anything with
navigator.webdriverset, such as Playwright, Puppeteer or Selenium. - Before a prerendered page is shown: it waits until someone actually sees it.
- From an opted-out device: visit any page with
?peepless-ignoreonce (?peepless-ignore=offundoes it). This is handy for your own devices. The choice is kept in that site's local storage and is never sent. You can rename the parameter withignoreParam. A privacy page can offer the same switch withoptOut(),optIn()andisOptedOut()frompeepless(or onwindow.peepless), and it takes effect at once.
The server also drops anything with a bot, crawler, previewer or tool in its User-Agent. That check is the only thing the User-Agent is used for. An address is used only to rate-limit (by default 60 beacons a minute from one address for one project) and is held in memory for that minute.
That limit lives in each server instance's memory, so on serverless hosts it
is per instance, not global: it blunts a script hammering one instance, not a
determined flood. The address comes from the first X-Forwarded-For entry by
default, which your host should set; where a client could set it, pass
address (below) to name the header your host controls.
Global Privacy Control
Peepless counts browsers that send Global Privacy Control
by default. GPC asks a site not to sell or share a person's data; peepless keeps
nothing about a person and shares nothing, so there is nothing for it to opt out
of, and honoring it would undercount. If you'd rather honor it anyway, pass
respectGPC: true to start (or data-respect-gpc on the script tag).
Server API
import { createHandler, supabaseStore, memoryStore } from 'peepless/server'
const handler = createHandler({
projects: { 'my-app': { origin: 'https://example.com', events: ['exported'], routes: ['/', '/blog/*'] } },
store: supabaseStore({ url, key }), // or memoryStore(), or your own { add(project, counters, day), read? }
perMinute: 60,
// country: (req) => req.headers.get('x-my-country'),
// address: (req) => req.headers.get('cf-connecting-ip'), // the header your host sets
// isBot: (ua) => isBot(ua) || /my-uptime-check/i.test(ua ?? ''), // add to the built-in list
})
// handler(request: Request): Promise<Response>
The handler only accepts beacons from the project's own origin, and refuses any event you didn't list. A wrong setting throws when the handler is created, so a typo fails at deploy time instead of silently counting nothing.
Reading: readCounts(store, { project, since, until }) returns { day, counter, count }
rows, summarize(rows, range?) turns them into a Summary, and
createStatsHandler({ store, token }) serves that over HTTP.
Stores: supabaseStore, postgresStore, d1Store (Cloudflare D1) and
memoryStore (tests). To write your own, see
docs/stores.md: peepless/testing checks it keeps the same
rules as the built-in ones.
Your privacy page
Something like this is accurate:
We count visits with peepless, which keeps daily totals only: how many pages were viewed, which sites, tagged links and countries visits came from, and how many times features were used. No cookies, identifiers, IP addresses or browsing history are stored, and nothing is shared with anyone else.
Versions
From 1.0, peepless follows semver, and docs/semver.md says what that covers: the
exports, the beacon, the counter names and the tables. Coming from 0.x? docs/migrating.md
lists every breaking change since 0.1. Every release is in the CHANGELOG.
License
MIT
The code is MIT. The Peepless name and logos, and everything in brand/, are not; see
brand/LICENSE and brand/TRADEMARKS.md.