Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@bonnard/react

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bonnard/react

Bonnard embedded analytics — React charts, dashboards, and hooks

latest
Source
npmnpm
Version
0.4.5
Version published
Maintainers
1
Created
Source

@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:

ComponentDescription
<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>

PropTypeDefaultDescription
configBonnardConfigSDK config (apiKey or fetchToken)
darkModeboolean | 'auto''auto'Dark mode control
palettePaletteName | string[]'tableau'Chart color palette
chartHeightnumber320Default chart height in px

useBonnardQuery(options)

OptionTypeDescription
queryQueryOptionsCube query (measures, dimensions, filters, etc.)
skipbooleanSkip execution (for conditional queries)

Returns { data, loading, error, refetch }.

License

MIT

FAQs

Package last updated on 23 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts