A simple, embeddable view counter badge for any website.
Track page views and unique
visitors with a beautiful SVG badge.
The easiest way to use View Count is with the hosted service. Just embed an image tag on your page.
<img src="https://view-count.cloudtion.com/views" alt="views" />
When the image loads, the counter reads the Referer header to identify
which page the badge is embedded on.
Each unique page URL gets its own view/visitor count.
The badge is cached by the browser (default: 30 minutes) to prevent excessive counting.
Unique visitors are tracked by hashing IP + User-Agent.
Install view-count as a library to run your own counter service. Powered by Firebase or Express.js with SQLite.
npm install view-count
import { createViewCounter } from 'view-count';
const counter = createViewCounter({
firebaseConfig: {
projectId: 'your-project-id',
clientEmail: 'your-service-account@project.iam.gserviceaccount.com',
privateKey: '-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n',
collectionName: 'view-counts',
},
});
// Use with Express
app.get('/views', counter.handler);
app.get('/visitors', counter.handler);
See the full documentation for Firebase Functions deployment, Vercel examples, and API reference.
Creates a new view counter instance.
Returns:
handler(req, res) - Express-compatible request handlergetStats(pageUrl) - Get stats for a page without incrementingrecordView(pageUrl, visitorId) - Manually record a viewpreview(count, mode?, color?) - Generate SVG without recording