Spoar

React

Provider, hook, click tracking and an error boundary.

import { AnalyticsProvider } from "@spoar/sdk/react";

export function Providers({ children }: { children: React.ReactNode }) {
  return <AnalyticsProvider client={analytics}>{children}</AnalyticsProvider>;
}
ExportDoes
AnalyticsProviderMakes the client available to hooks and components below it
useAnalytics<Events>()The client, typed by your events; a no-op client outside the provider
TrackClickWraps one element and sends a named event on click
ErrorBoundaryCatches render errors, records them with captureError and shows a fallback
useRoutePageviews(path, route)Sends a pageview with the route template for routers other than Next
computeRoute(pathname, params)Turns /blog/hello and { slug: "hello" } into /blog/[slug]