Birch UI v0.1
Pricing

Migrate an AG Grid app with the CLI

Move an existing AG Grid code base to Birch UI Grid with birchui-migrate, from a dry run and report to applying the changes and clearing manual steps.

Open .md

birchui-migrate rewrites AG Grid imports, components, column definitions, options, events and API calls across a code base and tells you what is left to do by hand. This recipe walks through a migration of a React app on a branch, in the order that keeps the diff reviewable.

1. Install#

Terminal
git switch -c migrate-to-birchui
npm install --save-dev @birchui/migrate typescript
npm install @birchui/core @birchui/react

Add @birchui/grid-pro if the app uses AG Grid Enterprise modules. The CLI adds the right Birch UI modules to the code, but not to package.json.

2. Dry run with a report#

Terminal
npx birchui-migrate "src/**/*.{ts,tsx,js,jsx}" --from ag-grid --report migration-report.md

Nothing is written. The output is a unified diff and a summary such as:

text
14 files scanned, 6 would change. 83 converted, 7 manual steps, 12 warnings. Estimated effort: about 3 hours.
Run again with --write to apply the changes.

migration-report.md lists, per file, what was converted, the manual steps as a checklist and the warnings. Share it with the team before you start; it doubles as the migration ticket.

Option Use
--from ag-grid Skip MUI X detection in a mixed code base
--framework react|vue|angular|js Override the framework detected from imports
--quiet Print only the summary, useful in CI
--write Apply the changes

3. Apply and format#

Terminal
npx birchui-migrate "src/**/*.{ts,tsx,js,jsx}" --from ag-grid --write
npx prettier --write src
git add -A && git commit -m "refactor: migrate grids to Birch UI"

Commit the tool's output on its own, before any manual change, so reviewers can tell generated edits from hand-written ones. Running the tool again on converted files changes nothing.

4. Work through the manual steps#

Each manual step leaves a marker comment with a link to the relevant docs section:

TSX
{
  field: 'status',
  /* birchui-migrate: cellRenderer: StatusBadge is a framework component; rewrite it as cell: (ctx) => string | Node, or mount the component into a DOM node you return (https://birchui.com/getting-started/migrating-from-ag-grid/#cell-renderers) */
  cell: StatusBadge,
},

Find them all and fix them one by one:

Terminal
grep -rn "birchui-migrate:" src

A typical fix for a cell renderer returns DOM instead of a component:

TypeScript
{
  field: 'status',
  header: 'Status',
  cell: ({ value }) => {
    const badge = document.createElement('span');
    badge.className = `status-badge status-${String(value).toLowerCase()}`;
    badge.textContent = String(value);
    return badge;
  },
}

Delete each marker once it is handled. When grep finds none, the code side of the migration is done.

5. Review the warnings#

Warnings mark code that was converted but behaves differently, for example a filter option with a different default. They do not leave markers, so go through the list in migration-report.md and tick them off.

6. Remove AG Grid#

Terminal
npm uninstall ag-grid-community ag-grid-enterprise ag-grid-react
npx tsc --noEmit

Type errors after the uninstall point at AG Grid types the tool could not reach, usually values built in another module.

Pitfalls#

  • Run it on everything at once. Column definitions imported from another file are only converted when that file is part of the run.
  • Commit first. --write edits files in place.
  • Theme classes. ag-theme-* wrappers become the theme option; custom AG Grid CSS needs to be redone with CSS custom properties.
  • License keys. LicenseManager.setLicenseKey calls are converted, but you need a Birch UI key. See Licensing.

↑ ↓ to move, Enter to open, Esc to close