Analytics Dashboard
Drop-in React component that renders a complete analytics dashboard — page views, visitors, bounce rate, top pages, referrers, countries, devices, browsers, and custom events. No Tailwind or external CSS required.
Installation
Section titled “Installation”npm install @saas-maker/analytics-uiPeer dependencies: react and react-dom (v18+).
import { AnalyticsDashboard } from '@saas-maker/analytics-ui';
function App() { return <AnalyticsDashboard apiKey="pk_your_api_key" />;}The component fetches data from the Foundry API using your project API key and renders the full dashboard inline.
| Prop | Type | Default | Description |
|---|---|---|---|
apiKey | string | — | Your project API key (required) |
period | 'today' | '7d' | '30d' | '90d' | 'all' | '30d' | Initial time period |
theme | 'light' | 'dark' | 'dark' | Color theme |
apiBaseUrl | string | 'https://api.sassmaker.com' | API base URL (for self-hosted) |
What it renders
Section titled “What it renders”- Period selector — toggle between Today, 7D, 30D, 90D, and All time
- Timeseries chart — page views and visitors over time (area chart)
- Summary cards — page views, unique visitors, bounce rate, pages per session
- Breakdown panels — top pages, top referrers, countries, devices, browsers, operating systems
- Custom events — event counts (only shown when events exist)
Theming
Section titled “Theming”The component supports dark and light themes. All styles are inline — no CSS imports or Tailwind configuration needed.
{/* Dark theme (default) */}<AnalyticsDashboard apiKey="pk_your_api_key" theme="dark" />
{/* Light theme */}<AnalyticsDashboard apiKey="pk_your_api_key" theme="light" />Next.js App Router
Section titled “Next.js App Router”The component uses React hooks (client-side only). In Next.js App Router, wrap it in a client component:
'use client';
import { AnalyticsDashboard } from '@saas-maker/analytics-ui';
export function AnalyticsDashboardWrapper({ apiKey }: { apiKey: string }) { return <AnalyticsDashboard apiKey={apiKey} />;}// page.tsx (server component)import { AnalyticsDashboardWrapper } from './analytics-dashboard';
export default function Page() { return <AnalyticsDashboardWrapper apiKey="pk_your_api_key" />;}TypeScript
Section titled “TypeScript”The package exports all types:
import type { AnalyticsDashboardProps, Period, DashboardData, DashboardSummary,} from '@saas-maker/analytics-ui';