ViewFlare
Serverless, low-cost telemetry counter for projects, docs, and deploy workflows. Runs as a Cloudflare Worker on D1, with a Hono API and SVG badges. Free tier, no credit card.

Previously called CFlair-Counter. Same project, same API, same public URL
(https://counter.vkrishna04.me) - only the name changed. Existing badges and
integrations keep working unchanged.
Why This Exists (STAR)
Situation
Teams need a dead-simple way to track project usage and show view badges across multiple repos without maintaining a custom backend.
Task
Provide a fast, low-cost telemetry API that can be integrated in minutes and run reliably on a serverless platform.
Action
This project implements:
- A Cloudflare Worker API for view tracking and stats.
- D1-backed persistence with a project cap and a daily write budget.
- SVG badge generation with style and color customization.
- Admin endpoints for protected project-level operations.
- CI health checks via Postman/Newman.
Result
You get a production-ready counter service that is:
- Easy to integrate: one
POST request to increment views.
- Easy to show: one image URL for a live SVG badge.
- Cost-efficient: minimal infra overhead on Cloudflare.
- Automated: CI verifies endpoint behavior continuously.
Run Your Own
git clone https://github.com/Life-Experimentalist/ViewFlare.git
cd ViewFlare
npm install
npm run setup
npm run setup checks your Cloudflare login, creates a D1 database, writes its
id into wrangler.toml, applies the schema, lists the nine settings and offers
to change any of them, prompts for an admin password through
wrangler secret put (it never sees the value itself), deploys, and prints your
URL. Answering nothing to the settings question keeps every shipped value, so
the whole thing is two Enters if you want the defaults. Every step is
idempotent, so re-run it if it stops partway.
Two commands rather than one because Windows PowerShell 5.1 has no &&.
The only prerequisite is a free Cloudflare account. If wrangler is not logged in
yet the script says so and stops; npx wrangler login fixes it.
A custom domain is optional and is the one step the script does not do: the
*.workers.dev URL works immediately. To use your own, once the zone is on the
same Cloudflare account:
npx wrangler deploy --domains counter.example.com
That creates the DNS record too, and later npm run deploy runs keep it
attached. Pass it as a flag rather than committing a routes entry, so a fork
never tries to claim your hostname.
Then day to day:
npm run dev # local instance on http://127.0.0.1:8788
npm run deploy # build, type-check and ship
docs/CLOUDFLARE-SETUP.md has the manual version of every step, and the
migration path if you deployed an older version on Cloudflare Pages.
Warning about bot protection
If you put ViewFlare on a domain with Cloudflare's Bot Fight Mode on, requests
from datacenter IPs can be challenged, and a challenge page arrives at a caller
as HTML where it expected JSON. It is scored on IP reputation and request
signature, so it is intermittent rather than a flat block. That affects CI runners and server-side callers,
not browsers. The *.workers.dev hostname is not on your zone, so it is not
subject to it. Bot Fight Mode is zone-level and outside the Ruleset Engine, so a
WAF skip rule cannot exempt a path from it.
Integration (Fast Path)
Increment views
fetch("https://your-domain.com/api/views/my-project", {
method: "POST",
keepalive: true,
}).catch(() => {});
Add a badge

CI ping example
- name: Increment docs counter
run: |
curl -fsS -X POST "https://your-domain.com/api/views/docs-build"
API Endpoints