Drop the kit in. Swap the vendor later.
Connectors, the query model, chart variants, and how colors follow the host site. For every drawing and its props, see Components.
01
Install
Pick a connector for the analytics tool you already use. The React package is the dashboard and the charts.
pnpm add @analytics-kit/react @analytics-kit/core @analytics-kit/next @analytics-kit/connector-vercelWingtics was called Analytics Kit until September 2026. The packages still publish under @analytics-kit/*; only the project name changed.
Also: @analytics-kit/connector-plausible, connector-ga4, connector-umami, connector-posthog, and connector-mock for tests. Import @analytics-kit/react/styles.css once.
02
AnalyticsProvider
One provider around the tree. Widgets and hooks read the connector, range, and theme from context. theme is light or dark — not a color palette.
import { AnalyticsProvider, Dashboard } from "@analytics-kit/react";
import { createVercelConnector } from "@analytics-kit/connector-vercel";
import "@analytics-kit/react/styles.css";
const connector = createVercelConnector({
token: process.env.VERCEL_TOKEN!,
projectId: process.env.VERCEL_PROJECT_ID!,
});
export function Stats() {
return (
<AnalyticsProvider connector={connector} theme="light" range="7d">
<Dashboard />
</AnalyticsProvider>
);
}| Prop | Type | Default | Notes |
|---|---|---|---|
connector | AnalyticsConnector | — | Required. Any package connector, mock, or createHttpConnector. |
range | DateRangeInput | "7d" | Preset (24h, 7d, 30d, 90d, 12mo, …) or { from, to }. |
theme | "light" | "dark" | "dark" | Sets data-ak-theme on the kit root. Host CSS still owns --chart-*. |
cacheTtlMs | number | 30000 | In-memory query cache on the connector. 0 disables it. |
03
Connectors
Same query() shape. Swap the constructor when you leave a vendor.
createVercelConnector{ token, projectId, teamId? }@analytics-kit/connector-vercelcreatePlausibleConnector{ apiKey, siteId }@analytics-kit/connector-plausiblecreateGa4Connector{ accessToken, propertyId }@analytics-kit/connector-ga4createUmamiConnector{ apiKey, websiteId, host? }@analytics-kit/connector-umamicreatePostHogConnector{ apiKey, projectId, host? }@analytics-kit/connector-posthogcreateMockConnector{ profile?, seed? }Deterministic data. profile: full | vercel | plausible | …
createHttpConnector{ endpoint }The browser talks to your route. Keys stay on the server.
04
Query model
Widgets never send vendor field names. They send a canonical AnalyticsQuery. The connector maps it.
const result = await connector.query({
range: "7d",
metrics: ["visitors", "pageviews"],
dimensions: ["path"],
granularity: "day",
limit: 8,
includePrevious: true,
});| Prop | Type | Default | Notes |
|---|---|---|---|
range | DateRangeInput | — | Required on the wire. Provider range is the default in useQuery. |
metrics | MetricId[] | — | visitors, pageviews, visits, bounceRate, avgDuration, viewsPerVisit, events. |
dimensions | DimensionId[] | — | path, referrer, country, device, browser, os, source, medium, campaign, eventName, host. |
granularity | "hour" | "day" | "week" | "month" | — | Time buckets for series. Omit for totals-only queries. |
filters | AnalyticsFilter[] | — | dimension + op (eq, neq, contains, in) + value. |
limit | number | — | Breakdown row cap. |
includePrevious | boolean | — | Previous-period totals for deltas on metric cards. |
Result: totals, series, breakdown, optional previous.totals. Hooks: useQuery, useRealtime, useCapabilities. If a connector cannot answer a metric, the widget renders an unsupported state instead of crashing.
05
Charts
Tailwind + Recharts. Eighteen types, funnel through sunburst, and the drawing is a variant — gradient, dither, hatched, glow — not a palette. Colors come from CSS variables on the host page.
import { AreaChart } from "@analytics-kit/react";
<AreaChart
data={points}
dataKey="value"
labelKey="date"
variant="gradient"
config={{ value: { label: "Visitors", color: "var(--chart-1)" } }}
/>| Prop | Type | Default | Notes |
|---|---|---|---|
AreaChart | gradient | linear | natural | step | dots | spark | dither | glow | hatched | bars | solid | gradient | Filled trend. hatched and bars are SVG textures; glow blooms the stroke. |
LineChart | monotone | linear | step | dashed | dots | dither | glow | ping | rainbow | values | monotone | Stroke only. ping pulses the last point; rainbow uses --chart-1…5. |
BarChart | vertical | horizontal | rounded | hatched | dither | glow | gradient | duotone | vertical | Breakdown bars. duotone is a hard two-band fill. |
PieChart | donut | pie | legend | dither | rounded | radial | glow | donut | Share of a dimension. radial is a RadialBar. |
FunnelChart | tape | steps | vertical | tape | Conversion stages with drop-off. |
RadarChart | stroke | fill | glow | dither | fill | Multi-axis comparison. |
ComposedChart | combo | highlight | overlay | combo | Two series on one axis. |
GaugeChart | arc | ring | tick | arc | Single-value dial. |
ScatterChart | dots | bubble | glow | dots | Correlation. bubble sizes by z. |
SankeyChart | flow | gradient | dither | flow | Flow between stages. nodes + links. |
CandlestickChart | ohlc | hollow | wick | ohlc | Open, high, low, close. |
ChoroplethChart | tiles | heat | dither | tiles | Region tiles by intensity. Not a geoJSON map. |
LiveLineChart | stream | glow | dashed | stream | Sliding window over a series. |
RingChart | stack | nested | track | stack | Concentric KPI rings. |
HeatmapChart | calendar | matrix | dither | calendar | A grid of intensity cells. |
SunburstChart | nest | burst | nest | Hierarchy as two rings. |
ProfitLossChart | fill | stroke | bars | fill | Signed series above and below zero. |
MetricCard | default | spark | compact | hero | default | Wired to a metric via useQuery. |
RankedList | bar | compact | table | bar | Breakdown rows with optional tracks. |
Shared chart props: data, dataKey, labelKey, variant, config, className. Full tables live on the components page.
06
Widgets & dashboard
Dashboard lays out registered widgets. defaultDashboard is the Vercel-friendly subset. catalogDashboard is every built-in widget — use it with a full-capability connector (mock profile full).
| Prop | Type | Default | Notes |
|---|---|---|---|
widgets | DashboardItem[] | defaultDashboard | { widget, span?, props? }. widget is a registry id such as "visitors". |
columns | number | 4 | Grid columns. span on an item stretches across. |
showRange | boolean | true | Preset range toolbar from the provider. |
Built-in ids: visitors, pageviews, visits, events, bounce-rate, duration, views-per-visit, realtime, timeseries, top-pages, top-referrers, top-countries, devices, top-browsers, top-os, top-sources, top-campaigns, top-events, pages-table, tracker.
07
Colors follow the host
There is no kit “theme pack.” Set the same variables you would on a shadcn page. The kit reads them through --ak-chart-* fallbacks.
:root {
--chart-1: #0070f3;
--chart-2: #7d5bed;
--chart-3: #f5a623;
--chart-4: #12a594;
--chart-5: #e5484d;
--card: #fff;
--foreground: #000;
--primary: #0070f3;
--border: #e6e6e6;
--muted: #fafafa;
--muted-foreground: #666;
}Per-series override: pass config on Area, Line, and Bar. config.value.color can be any CSS color, including var(--chart-1).
08
Keys stay on the server
Do not put vendor tokens in the browser bundle. @analytics-kit/next proxies the connector. The client uses createHttpConnector.
import { createVercelConnector } from "@analytics-kit/connector-vercel";
import { createRouteHandlers } from "@analytics-kit/next";
const connector = createVercelConnector({
token: process.env.VERCEL_TOKEN!,
projectId: process.env.VERCEL_PROJECT_ID!,
});
export const { GET, POST } = createRouteHandlers({ connector });Browser: createHttpConnector({ endpoint: "/api/analytics" }). This site does that in app/api/analytics/route.ts. Also examples/next-app-route.ts.
09
shadcn registry
Copy a chart or the dashboard into your app. You own the file. Runtime still comes from npm so the query model stays canonical.
pnpm dlx shadcn@latest add /r/dashboard.jsonItems: every catalog chart plus metric-card and dashboard. Also educlopez/analytics-kit/dashboard from the GitHub registry.
10
Extend
defineConnector and defineWidget are the extension points. Register custom metrics and dimensions, or merge them into MetricCatalog / DimensionCatalog. See examples/custom-connector.ts and examples/custom-widget.tsx.