# Grid Pro overview and activation

> What Grid Pro adds to Birch UI Grid, how to install and register its modules, and how to activate a license key.

Grid Pro is the commercial layer on top of the MIT-licensed [Birch UI Grid](https://docs.birchui.com/grid/overview.md). It does not replace the grid: you keep calling `createGrid()` from `@birchui/core`, and you add Pro features by passing modules from `@birchui/grid-pro` in the `modules` option. Everything you already know about columns, sorting, filtering and editing carries over unchanged.

> **Grid Pro: Paid feature. Fully functional without a key; a license removes the watermark. Pricing: https://docs.birchui.com/getting-started/pricing.md**
>
> Grid Pro is a one-time purchase per developer with free updates forever, including major versions. You can install it and use every feature without a key while you evaluate; the only difference is a small watermark on non-local hosts. See [Licensing & activation](https://docs.birchui.com/getting-started/licensing.md) for the rules.

## What Grid Pro adds

| Feature | Module | Options it reads | Guide |
| --- | --- | --- | --- |
| Row grouping and the group panel | `RowGroupingModule` | `groupBy`, `rowGroup`, `groupPanel`, `groupDefaultExpanded`, `groupColumn`, `groupTotals` | [Row grouping](https://docs.birchui.com/grid-pro/row-grouping.md) |
| Aggregation | `AggregationModule` | `aggFunc` on columns | [Aggregation](https://docs.birchui.com/grid-pro/aggregation.md) |
| Tree data | `TreeDataModule` | `treeData`, `getDataPath`, `getParentId` | [Tree data](https://docs.birchui.com/grid-pro/tree-data.md) |
| Pivot mode | `PivotModule` | `pivot` | [Pivoting](https://docs.birchui.com/grid-pro/pivoting.md) |
| Range selection | `RangeSelectionModule` | `rangeSelection` | [Range selection](https://docs.birchui.com/grid-pro/range-selection.md) |
| Clipboard copy, cut and paste | `ClipboardModule` | `clipboard` (on by default) | [Clipboard](https://docs.birchui.com/grid-pro/clipboard.md) |
| Fill handle | `FillHandleModule` | `fillHandle`, with range selection on | [Fill handle](https://docs.birchui.com/grid-pro/fill-handle.md) |
| Master/detail rows | `MasterDetailModule` | `masterDetail` | [Master/detail](https://docs.birchui.com/grid-pro/master-detail.md) |
| Status bar | `StatusBarModule` | `statusBar` | [Status bar](https://docs.birchui.com/grid-pro/status-bar.md) |
| Styled Excel export and import | `ExcelModule` | none; adds API methods and a column menu item | [Excel export & import](https://docs.birchui.com/grid-pro/excel-export.md) |

All of these options are part of the regular [`GridOptions`](https://docs.birchui.com/api/core.md#gridoptions) type, so they are typed and documented in one place. An option only takes effect when the module that reads it is installed. If you set `groupBy` without `RowGroupingModule`, the grid ignores the option and logs one console warning that names the missing module.

You can change the installed modules at runtime with `api.update({ modules })`. Modules you add are installed, and modules you leave out are uninstalled and clean up after themselves.

## Install

Grid Pro depends on the grid core, the license verifier and the Excel Engine. npm installs the last two for you.

```bash
npm install @birchui/core @birchui/grid-pro
```

The package is ESM only and has no side effects on import, so it is safe to import in server-rendered code. All DOM work starts inside `createGrid()`. Styles for Pro features are injected automatically the first time a module is installed. If you set `injectStyles: false` on the grid, import the stylesheet yourself:

```ts
import '@birchui/core/styles.css';
import '@birchui/grid-pro/styles.css';
```

## Register modules

Pass the modules you need. Each module is a small object with a `name` and an `install()` function. Bundlers drop the modules you do not import.

```ts title="sales-grid.ts"
import { createGrid, type ColumnDef } from '@birchui/core';
import { RowGroupingModule, AggregationModule, StatusBarModule } from '@birchui/grid-pro';

interface Sale {
  id: string;
  region: 'EMEA' | 'North America' | 'APAC' | 'LATAM';
  country: string;
  rep: string;
  product: string;
  units: number;
  revenue: number;
}

const sales: Sale[] = [
  { id: 'S-2041', region: 'EMEA', country: 'Germany', rep: 'Lena Fischer', product: 'Edge Router X2', units: 40, revenue: 18400 },
  { id: 'S-2042', region: 'EMEA', country: 'France', rep: 'Hugo Martin', product: 'Fleet Tracker', units: 12, revenue: 5520 },
  { id: 'S-2043', region: 'North America', country: 'Canada', rep: 'Maya Singh', product: 'Edge Router X2', units: 75, revenue: 33750 },
  { id: 'S-2044', region: 'APAC', country: 'Japan', rep: 'Kenji Ito', product: 'Sensor Hub', units: 30, revenue: 11970 },
];

const columns: ColumnDef<Sale>[] = [
  { field: 'region', rowGroup: true },
  { field: 'country', rowGroup: true },
  { field: 'rep', header: 'Sales rep' },
  { field: 'product' },
  { field: 'units', type: 'number', aggFunc: 'sum' },
  { field: 'revenue', type: 'number', aggFunc: 'sum', format: (v) => `$${Number(v).toLocaleString('en-US')}` },
];

const api = createGrid(document.querySelector<HTMLElement>('#sales')!, {
  columns,
  rows: sales,
  getRowId: (row) => row.id,
  modules: [RowGroupingModule, AggregationModule, StatusBarModule],
  groupDefaultExpanded: 1,
  statusBar: true,
});
```

To turn on everything at once, use `AllProModules`. It is convenient for prototypes and internal tools. Production bundles are smaller when you list the modules you use.

```ts
import { AllProModules } from '@birchui/grid-pro';

createGrid(container, { columns, rows, modules: AllProModules });
```

Modules can be combined with your own [custom modules](https://docs.birchui.com/grid/modules.md) in the same array. Order does not matter; each module registers pipeline stages with a fixed position, so grouping always runs after filtering and sorting.

## Use Grid Pro in your framework

The framework adapters pass options straight through to `createGrid()`, so `modules` and every Pro option work the same way everywhere. Define the modules array once, outside your component, so its identity stays stable between renders.

**JavaScript**

```ts
import { createGrid } from '@birchui/core';
import { AllProModules } from '@birchui/grid-pro';

const api = createGrid(document.getElementById('sales')!, {
  columns,
  rows: sales,
  modules: AllProModules,
  groupBy: ['region'],
  licenseKey: import.meta.env.VITE_BIRCHUI_LICENSE_KEY,
});
```

**React**

```tsx
import { BirchGrid } from '@birchui/react';
import { AllProModules } from '@birchui/grid-pro';

const modules = AllProModules;

export function SalesGrid({ sales }: { sales: Sale[] }) {
  return (
    <BirchGrid<Sale>
      style={{ height: 480 }}
      columns={columns}
      rows={sales}
      modules={modules}
      groupBy={['region']}
      onRowExpanded={(e) => console.log(e.rowId, e.expanded)}
    />
  );
}
```

**Vue**

```vue
<script setup lang="ts">
import { BirchGrid } from '@birchui/vue';
import { AllProModules } from '@birchui/grid-pro';

defineProps<{ sales: Sale[] }>();
const modules = AllProModules;
</script>

<template>
  <BirchGrid
    style="height: 480px"
    :columns="columns"
    :rows="sales"
    :modules="modules"
    :group-by="['region']"
    @row-expanded="(e) => console.log(e.rowId, e.expanded)"
  />
</template>
```

**Angular**

```ts
import { Component, input } from '@angular/core';
import { BirchGridComponent } from '@birchui/angular';
import { AllProModules } from '@birchui/grid-pro';
import type { GridOptions } from '@birchui/core';

@Component({
  selector: 'app-sales-grid',
  standalone: true,
  imports: [BirchGridComponent],
  template: `
    <birchui-grid
      style="height: 480px"
      [columns]="columns"
      [rows]="sales()"
      [options]="options"
      (rowExpanded)="onExpanded($event)"
    />
  `,
})
export class SalesGridComponent {
  readonly sales = input<Sale[]>([]);
  readonly columns = columns;
  readonly options: Partial<GridOptions<Sale>> = { modules: AllProModules, groupBy: ['region'] };

  onExpanded(e: { rowId: string; expanded: boolean }) {
    console.log(e.rowId, e.expanded);
  }
}
```

**Svelte**

```svelte
<script lang="ts">
  import { BirchGrid } from '@birchui/svelte';
  import { AllProModules } from '@birchui/grid-pro';

  let { sales }: { sales: Sale[] } = $props();
  const modules = AllProModules;
</script>

<BirchGrid style="height: 480px" {columns} rows={sales} {modules} groupBy={['region']} />
```

The [framework guides](https://docs.birchui.com/frameworks/react.md) cover typed generics, refs to the grid API and server-side rendering for each adapter.

## Calling Pro API methods

Pro modules add methods to the grid API object when they install, and remove them when they are uninstalled.

Importing `@birchui/grid-pro` declares these methods on `GridApi` as optional members, because each one exists only while the module that provides it is installed. Call them with optional chaining, or check for the module first:

```ts
import { RangeSelectionModule } from '@birchui/grid-pro';

if (api.hasModule(RangeSelectionModule.name)) {
  console.log(api.getCellRanges?.());
}

await api.exportExcel?.({ fileName: 'q3-sales.xlsx' });
api.setGroupBy?.(['region', 'rep']);
const revenue = api.getColumnAggregate?.('revenue');
```

| Module | Methods |
| --- | --- |
| `RowGroupingModule` | `setGroupBy()`, `getGroupBy()`, `expandToLevel()` |
| `AggregationModule` | `getColumnAggregate()` |
| `TreeDataModule` | `expandToLevel()` |
| `PivotModule` | `setPivot()`, `getPivotResult()`, `expandToLevel()` |
| `RangeSelectionModule` | `getCellRanges()`, `setCellRange()`, `addCellRange()`, `clearCellRanges()`, `getRangeValues()`, `onRangeChanged()` |
| `ClipboardModule` | `copyToClipboard()`, `cutToClipboard()`, `pasteFromClipboard()`, `pasteText()` |
| `MasterDetailModule` | `setDetailExpanded()`, `isDetailExpanded()` |
| `ExcelModule` | `exportExcel()`, `getExcelBlob()`, `buildExcelWorkbook()`, `importExcel()` |

Module names, for `hasModule()`, are `rowGrouping`, `aggregation`, `treeData`, `pivot`, `rangeSelection`, `clipboard`, `fillHandle`, `masterDetail`, `statusBar` and `excel`. Each module object exposes its name as `.name`.

## Activate your license key

Your key arrives by email after purchase, and you can retrieve it again from the customer portal. It looks like `LQ1.eyJ2IjoxLCJpZCI6...` followed by a signature. There are two ways to give it to the grid.

### Set the key once for the whole app

Call `setLicenseKey()` from `@birchui/license` before or after creating grids. Every Birch UI widget that has no key of its own picks it up, including grids that already exist; their watermark disappears as soon as the key is verified.

```ts title="main.ts"
import { setLicenseKey } from '@birchui/license';

setLicenseKey(import.meta.env.VITE_BIRCHUI_LICENSE_KEY);
```

This is the recommended approach. One call covers Grid Pro, the [Scheduler](https://docs.birchui.com/scheduler/overview.md) and any other Birch UI product your key includes.

### Pass the key to one grid

The `licenseKey` grid option takes precedence over the global key. Use it when different parts of a page are licensed separately, for example in a micro-frontend.

```ts
createGrid(container, {
  columns,
  rows,
  modules: AllProModules,
  licenseKey: 'LQ1.eyJ2IjoxLCJpZCI6...',
});
```

The grid reads `licenseKey` when the first Pro module installs, so set it in the options you pass to `createGrid()`. A grid created with its own key ignores later `setLicenseKey()` calls.

> **Tip**
>
> Your key covers the [Excel Engine](https://docs.birchui.com/excel/overview.md) too. Grid Pro includes it, so `@birchui/excel` used on its own is licensed by the same key, and `ExcelModule` passes the grid's `licenseKey` to the engine when it exports or imports.

## What happens without a valid key

Birch UI never disables a feature because of licensing. When the key is missing, malformed, signed for a different product or an expired trial:

- every Pro feature keeps working exactly as it does with a key;
- the grid shows a small, non-interactive watermark in its bottom-right corner, for example `Birch UI Grid Pro · unlicensed copy · birchui.com/pricing`;
- the console shows one warning per product per page load, explaining what is wrong with the key.

On `localhost`, `127.0.0.1`, `[::1]` and hostnames ending in `.localhost` or `.local`, the watermark is not shown, so local development stays clean. The console warning still appears, which helps you notice a missing key before you deploy.

Verification happens in the browser against a public key embedded in the package. There are no network calls, no activation server and no phone-home. Paid keys never expire, which is how free updates forever work offline: a newer version of Grid Pro accepts the same key.

## Next steps

- Group rows and add totals: [Row grouping](https://docs.birchui.com/grid-pro/row-grouping.md) and [Aggregation](https://docs.birchui.com/grid-pro/aggregation.md).
- Turn a flat list into a report: [Pivoting](https://docs.birchui.com/grid-pro/pivoting.md).
- Give users spreadsheet-style interaction: [Range selection](https://docs.birchui.com/grid-pro/range-selection.md), [Clipboard](https://docs.birchui.com/grid-pro/clipboard.md) and [Fill handle](https://docs.birchui.com/grid-pro/fill-handle.md).
- Hand data to Excel: [Excel export & import](https://docs.birchui.com/grid-pro/excel-export.md).
- Look up every option: [`GridOptions` reference](https://docs.birchui.com/api/core.md#gridoptions) and the [`@birchui/grid-pro` API](https://docs.birchui.com/api/grid-pro.md).
