@humlabs/core
v0.2.2
Published
Headless SDK for Hum visitor counters
Downloads
763
Maintainers
Readme
@humlabs/core
Headless SDK for Hum visitor counters. Framework-agnostic, zero dependencies.
Installation
npm install @humlabs/coreQuick Start
import { HumClient } from '@humlabs/core';
const hum = new HumClient({
siteId: 'site_abc123',
// apiUrl?: string — override API base (default: https://api.humlabs.io)
// debug?: boolean — enable verbose logging
});
// Track a visitor (all options are optional)
await hum.track({
path: '/blog/my-post', // defaults to current pathname
referrer: document.referrer, // defaults to empty string
template: 'minimal-pill', // badge template slug for dashboard analytics
});
// Get current count
const count = await hum.getCount('unique'); // 'unique' | 'views' | 'online'
console.log(`${count} visitors`);
// Subscribe to realtime updates
const unsubscribe = hum.subscribe((count) => {
console.log(`${count} online now`);
});
// Call unsubscribe() to stop listeningDevelopment
Watch Mode (Auto-rebuild)
npm run devThis will watch for changes and automatically rebuild the package.
Build Once
npm run buildRun Tests
npm testLicense
MIT
