npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bonnard/react

v0.4.5

Published

Bonnard embedded analytics — React charts, dashboards, and hooks

Readme

@bonnard/react

React components for embedding Bonnard charts and dashboards in any React app.

Install

npm install @bonnard/react @bonnard/sdk

Quick Start

1. Add the provider

import { BonnardProvider } from '@bonnard/react';
import '@bonnard/react/styles.css';

function App() {
  return (
    <BonnardProvider config={{ apiKey: 'bon_pk_...' }}>
      <MyAnalyticsPage />
    </BonnardProvider>
  );
}

2. Render a chart

import { BarChart } from '@bonnard/react';

function RevenueByCategory() {
  return (
    <BarChart
      title="Revenue by Category"
      measures={['orders.revenue']}
      dimensions={['orders.product_category']}
    />
  );
}

3. Use the query hook

import { useBonnardQuery } from '@bonnard/react';

function OrderStats() {
  const { data, loading, error } = useBonnardQuery({
    query: {
      measures: ['orders.revenue', 'orders.count'],
      dimensions: ['orders.status'],
    },
  });

  if (loading) return <p>Loading...</p>;
  if (error) return <p>Error: {error}</p>;

  return (
    <ul>
      {data?.map((row, i) => (
        <li key={i}>{row['orders.status']}: ${row['orders.revenue']}</li>
      ))}
    </ul>
  );
}

Charts

All chart components accept data inline or query props:

| Component | Description | |-----------|-------------| | <BarChart> | Vertical or horizontal bar chart | | <LineChart> | Line chart with optional time axis | | <AreaChart> | Stacked or overlapping area chart | | <PieChart> | Pie / donut chart | | <BigValue> | Single KPI number with optional comparison | | <DataTable> | Sortable, paginated data table | | <BonnardChart> | Universal renderer — pass a spec object |

Dashboards

For rendering markdown dashboards in React apps, use the dashboard sub-entry:

import { DashboardViewer } from '@bonnard/react/dashboard';

// Render from markdown content
<DashboardViewer content={markdownString} />

Dashboards are markdown files with YAML query blocks and chart component tags (<BigValue>, <LineChart>, <BarChart>, etc.). See bon docs dashboards for the full format reference.

The dashboard entry adds parser dependencies (gray-matter, remark, rehype). Only import it if you need it — the main entry stays lightweight.

Theming

Dark mode

<BonnardProvider config={{ apiKey: '...' }} darkMode={true}>

Options: true, false, or 'auto' (default — uses prefers-color-scheme).

Custom colors

Override CSS custom properties to match your brand:

:root {
  --bon-bg: #fafafa;
  --bon-text: #1a1a1a;
  --bon-border: #e0e0e0;
  --bon-radius: 12px;
}

Color palettes

<BonnardProvider config={{ apiKey: '...' }} palette="observable">

Built-in palettes: default, tableau, observable, metabase. Or pass a custom array of hex colors.

API

<BonnardProvider>

| Prop | Type | Default | Description | |------|------|---------|-------------| | config | BonnardConfig | — | SDK config (apiKey or fetchToken) | | darkMode | boolean \| 'auto' | 'auto' | Dark mode control | | palette | PaletteName \| string[] | 'tableau' | Chart color palette | | chartHeight | number | 320 | Default chart height in px |

useBonnardQuery(options)

| Option | Type | Description | |--------|------|-------------| | query | QueryOptions | Cube query (measures, dimensions, filters, etc.) | | skip | boolean | Skip execution (for conditional queries) |

Returns { data, loading, error, refetch }.

Links

License

MIT