Overview
v0.1 — client-only analytics hooks; bring your own database.
What this is
- React hooks for reading analytics data from your own Hono server.
- Central config via a provider; hooks call GET
{endpoint}/metricswith x-api-key. - Features: request deduplication, optional caching with TTL, polling with exponential backoff, date range validation, TypeScript types.
Version note
- This is v0.1. Client only.
- No server or storage is included. You bring your own database and implement the /metrics route on your Hono server.
Install
bun add honolyticsSetup
import { HonolyticsProvider } from 'honolytics'
export function App() {
return (
<HonolyticsProvider
apiKey={process.env.NEXT_PUBLIC_ANALYTICS_KEY!}
endpoint={process.env.NEXT_PUBLIC_ANALYTICS_URL!}
>
<YourApp />
</HonolyticsProvider>
)
}Use
import { useTotals, useAnalytics } from 'honolytics'
// Totals only
const { data: totals, loading, error } = useTotals()
// Full payload + options
const { data, refetch } = useAnalytics({
dateRange: { from: new Date('2024-01-01'), to: new Date('2024-12-31') },
pollingInterval: 30000,
maxRetries: 3,
enableCache: true,
cacheTTL: 5000
})Next
- API Reference: ./api-reference
- Server Contract: ./server-contract