# React Native analytics dashboard template (Pro)

> A React Native web analytics dashboard for iOS, Android and the web, like Plausible, PostHog and Datadog: KPIs that tick, revenue against the previous period, live visitors, a sign-up funnel, top pages, countries, devices, channels and weekly retention cohorts. A date range with presets, compare and filters, and an Edit dashboard mode to drag, resize, remove and add widgets. Built on Patine Pro's DashboardGrid and charts, no native modules.

# Analytics dashboard Pro

A web analytics dashboard people arrange themselves. Key metrics count up to their values, revenue is drawn against the previous period (daily or weekly), live visitors tick every few seconds, and below sit a sign-up funnel, top pages, countries, devices, channels and weekly retention. A date range with presets or a calendar, **Compare** and filters by country, device and channel sit up top, and change every widget at once.

**Edit dashboard** turns the widgets into a [DashboardGrid](../blocks/dashboard-grid): drag to move, pull a corner to resize, ✕ removes with Undo, **Add widget** opens a gallery, and **Reset layout** puts everything back. On phones the widgets stack and a long press reorders them. The data is generated from a seed, so it looks real and never changes between runs.

```tsx
import { AnalyticsDashboardScreen } from '@patine-ui/pro';

<AnalyticsDashboardScreen />;
```

```tsx live full
import { View } from 'react-native';
import { AnalyticsDashboardScreen } from '@patine-ui/pro';

export default function Example() {
  return (
    <View style={{ width: '100%', height: 900 }}>
      <AnalyticsDashboardScreen />
    </View>
  );
}
```

| Prop | Type | Default |
| --- | --- | --- |
| `demo` | `'ready'` \| `'loading'` \| `'empty'` \| `'error'` | `'ready'` |
| `seed` | `number`: the same seed draws the same numbers | `7` |
| `today` | `Date`, the data's last day | Nov 16, 2026 |
| `defaultEditing` | `boolean`: starts in edit mode | `false` |
| `site` | `string`, in the subtitle | `'northwind.dev'` |

## Make it yours

Copy the screen and swap `analyticsFor(range, seed, filters)` for your own query: it returns `AnalyticsData` (days, totals, the previous period, funnel, pages, countries, cohorts, devices and channels), so each widget keeps working. `ANALYTICS_WIDGETS` lists the widgets the gallery offers and `ANALYTICS_LAYOUT` and `ANALYTICS_LAYOUTS` the starting arrangement; save what `onLayoutChange` gives you to keep each person's dashboard. `lastDays(today, n)` and `previousRange(range)` work out the ranges.

## Built with

The free components, from `patine-ui`:

[BottomSheet](/docs/components/bottom-sheet) · [Button](/docs/components/button) · [Calendar](/docs/components/date-picker) · [DropdownMenu](/docs/components/dropdown-menu) · [Switch](/docs/components/switch) · [Text](/docs/components/text)

And from Patine Pro:

- [Bar chart](/docs/components/bar-chart) PRO
- [Combo chart](/docs/components/combo-chart) PRO
- [Dashboard grid](/docs/pro/layout) PRO
- [Funnel chart](/docs/components/funnel-chart) PRO
- [Patine Icons, the Pro set](/docs/components/icons) PRO
- [Pie chart](/docs/components/pie-chart) PRO
- [Sparkline](/docs/components/sparkline) PRO

## Files

```text
analytics/
├── components/
│   ├── AnalyticsWidget.tsx
│   ├── KpiStrip.tsx
│   ├── Panels.tsx
│   └── Toolbar.tsx
├── hooks/
│   ├── useAnalytics.ts
│   └── useRealtime.ts
├── analytics.constants.ts
├── analytics.types.ts
├── analytics.utils.ts
├── AnalyticsDashboardScreen.tsx
└── index.ts
```

## A look at the code

A range’s headline numbers and their change, from `analytics.utils.ts`:

```tsx
/** A range's headline numbers: sums, and the rates weighted by sessions. */
export const totalsOf = (days: readonly DayMetrics[]): Totals => {
  const sum = (pick: (d: DayMetrics) => number) => days.reduce((n, d) => n + pick(d), 0);
  const sessions = sum((d) => d.sessions);
  return {
    visitors: sum((d) => d.visitors),
    pageviews: sum((d) => d.pageviews),
    bounceRate: sessions ? sum((d) => d.bounces) / sessions : 0,
    avgSession: sessions ? sum((d) => d.sessionSeconds) / sessions : 0,
    conversions: sum((d) => d.conversions),
    revenue: Math.round(sum((d) => d.revenue)),
  };
};

/** The change from `previous` as a ratio: 0.12 is +12%. Undefined without a previous value. */
export const change = (current: number, previous: number) => (previous ? (current - previous) / previous : undefined);
```

Get the source with Pro
