@jillen/analytics
Version:
Lightweight human-visit and Web Vitals analytics for React apps. Framework-agnostic core with a Next.js adapter.
33 lines (29 loc) • 1.26 kB
TypeScript
import * as react from 'react';
interface VisitorTrackerProps$1 {
username?: string | null;
/**
* Current route pathname. Required — pass from your router:
*
* • Next.js: `usePathname()` from `next/navigation`
* (or use the `@jillen/analytics/next` adapter,
* which wires this for you).
* • React Router: `useLocation().pathname`
* • TanStack Router: `useRouterState({ select: s => s.location.pathname })`
* • Astro / vanilla: `window.location.pathname` and re-render on
* route change.
*/
pathname: string;
}
type VisitorTrackerProps = Omit<VisitorTrackerProps$1, "pathname">;
/**
* Next.js adapter for VisitorTracker. Reads the current pathname via
* `usePathname()` from `next/navigation` and forwards it to the
* framework-agnostic core.
*
* Use this in a Next.js App Router project. For other React frameworks
* (Vite, React Router, TanStack Router, Astro, etc.), import the core
* from `@jillen/analytics` directly and pass `pathname` from your
* router state.
*/
declare function VisitorTracker(props: VisitorTrackerProps): react.JSX.Element;
export { VisitorTracker, type VisitorTrackerProps };