React 19 Plugin Migration
Grafana LabsOfficialPublished by Grafana Labs
- Skill
- Workflow
- Cloud and DevOps
- Apache-2.0
- Low risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured procedure for updating Grafana plugins to ensure compatibility with React 19, which is introduced in Grafana 13. It covers environment detection, scaffolding updates via create-plugin, dependency management, and source code adjustments. The process emphasizes maintaining forward compatibility without upgrading the local React version, ensuring the plugin remains stable within the Grafana ecosystem.
What it does
- Detects plugin environment and configuration
- Updates scaffolding using @grafana/create-plugin
- Externalizes jsx-runtime to prevent runtime crashes
- Bumps core Grafana and Faro dependencies
- Provides manual fixes for deprecated React patterns
- Offers troubleshooting steps for common migration errors
When to use it
- When preparing a Grafana plugin for the Grafana 13 release
- When encountering React 19 compatibility issues
- When needing to bump grafanaDependency to 12.3.0
- When resolving ReactCurrentOwner or ReactCurrentDispatcher errors
Advantages
- Ensures plugin stability in the upcoming Grafana 13 environment
- Standardizes the migration process across different plugin types
- Provides clear paths for resolving common dependency and build errors
- Includes specific guidance for complex issues like i18n initialization
Usage examples
- “How do I update my plugin for React 19?”
- The agent will initiate the migration workflow, starting with environment detection and scanning for compatibility issues.
- “My plugin crashes with ReactCurrentOwner error, what should I do?”
- The agent will guide you through bumping @grafana-cloud dependencies and externalizing jsx-runtime to resolve the crash.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/grafana/react-19-plugin-migration/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip react-19-plugin-migration.zip -d .agents/skills
Documentation by Grafana Labs
Migrate Grafana Plugin to React 19
Grafana 13 (April 2026) moves from React 18 to React 19. Incompatible plugins will break. Do not upgrade React to 19 — only make forward-compatible changes.
All changes go in one PR. Execute steps in order. Never manually edit yarn.lock.
Step 1: Detect plugin context
PLUGIN_JSON=$([ -f src/plugin.json ] && echo "src/plugin.json" \
|| ([ -f plugin/src/plugin.json ] && echo "plugin/src/plugin.json" || echo ""))
PKG_JSON=$([ -f package.json ] && echo "package.json" \
|| ([ -f plugin/package.json ] && echo "plugin/package.json" || echo ""))
PLUGIN_ID=$(jq -r '.id' $PLUGIN_JSON 2>/dev/null)
[ -f yarn.lock ] && PM="yarn" || ([ -f pnpm-lock.yaml ] && PM="pnpm" || PM="npm")
CP_VERSION=$(jq -r '.version' .config/.cprc.json 2>/dev/null)
echo "PLUGIN_ID=$PLUGIN_ID PM=$PM CP=$CP_VERSION"If PLUGIN_ID is empty, ask the user for the plugin root path.
Step 2: Scan for compatibility issues
Build the plugin and run the React 19 compatibility scanner:
npm run build 2>&1 | tail -5
npx -y @grafana/react-detect@latest 2>&1Save the output. It flags:
jsxRuntimeImport/__SECRET_INTERNALS→ Step 4 fixes thisdefaultProps/propTypes/ReactDOM.render→ Step 8 (source fixes)findDOMNode→ Step 6 (dependency bump) or Step 8 (source fix)
If the build fails (plugin hasn't been built before), skip this step and run react-detect after Step 9 instead. If output says "No breaking changes detected", still proceed — jsx-runtime externalization and grafanaDependency bump are always required.
Re-run react-detect after Step 9 to confirm all issues are resolved.
Step 3: Update @grafana/create-plugin
The scaffolding update brings in externals extraction, jest mocks, Docker fixes, and webpack
improvements needed for React 19. Always do this before add externalize-jsx-runtime.
Requires a clean git working tree. Create a feature branch first if not already on one.
Run the update
npx @grafana/create-plugin@latest update 2>&1If yarn install fails with "engine is incompatible"
The update runs an intermediate yarn install without --ignore-engines. Complete it manually:
yarn install --ignore-scripts --ignore-engines 2>&1 | tail -10Commit the intermediate state and re-run:
git add -A && git commit -m "chore: intermediate create-plugin update" --no-verify
npx @grafana/create-plugin@latest update 2>&1If ESLint 9 migration (004) fails with a parser error
The auto-migration can generate invalid JS on plugins with complex ESLint configs. Do not skip — commit what succeeded, then complete the ESLint 9 migration manually:
git add -A && git commit -m "chore: update create-plugin (ESLint 9 migration manual)" --no-verifyThen follow the "Complete ESLint 9 migration" section below to finish.
After the update
Always run install and verify:
yarn install --ignore-scripts --ignore-engines 2>&1 | tail -10
cat .config/.cprc.jsonCommit if there are changes:
git add -A && git diff --cached --quiet || git commit -m "chore: update create-plugin scaffolding" --no-verifyStep 3b: Complete ESLint 9 migration
The create-plugin update bumps ESLint to v9, which requires flat config (eslint.config.js)
instead of .eslintrc. Whether the auto-migration (004) succeeded, partially succeeded, or
failed, you must ensure ESLint works before proceeding.
Check the current state
ls eslint.config.js .eslintrc* .config/.eslintrc* 2>/dev/null
npx eslint --version 2>&1Three scenarios:
A) eslint.config.js exists and yarn lint passes — auto-migration succeeded. Proceed.
B) eslint.config.js exists but yarn lint fails — partial migration. Fix the issues:
yarn lint 2>&1 | head -30Common fixes:
Invalid option '--ignore-path'orInvalid option '--ext'→ remove those flags from thelintscript inpackage.json. In ESLint v9 flat config, ignores and file matching are configured insideeslint.config.js, not via CLI flags. Update to:eslint --cache .Cannot find module 'eslint-plugin-deprecation'→ remove the import/reference fromeslint.config.js(replaced by@typescript-eslint/no-deprecated)Other dead plugin imports → remove them from the config if the package was removed
C) No eslint.config.js exists — auto-migration failed. Create one manually:
ls node_modules/@grafana/eslint-config/flat.js 2>/dev/nullIf flat.js exists, create eslint.config.js using it as the base:
import grafanaConfig from '@grafana/eslint-config/flat';
export default [
...grafanaConfig,
{
ignores: ['**/dist/', '**/node_modules/', '**/.config/', '**/coverage/'],
},
];Then migrate any custom rules from the old .eslintrc into additional config objects in the array.
After creating the flat config:
Update the
lintscript:"lint": "eslint --cache ."Delete the root
.eslintrc(leave.config/.eslintrc— it's scaffolded and harmless)
Verify lint works
yarn lint 2>&1 | tail -20Fix auto-fixable issues with yarn lint --fix. Commit:
git add -A && git diff --cached --quiet || git commit -m "chore: complete ESLint 9 flat config migration" --no-verifyStep 4: Externalize jsx-runtime
Always use the create-plugin add command. Requires a clean git working tree.
npx @grafana/create-plugin@latest add externalize-jsx-runtime 2>&1Verify:
grep "jsx-runtime" .config/bundler/externals.ts 2>/dev/nullFound → commit and proceed.
Not found → command failed. Only then add externals manually to the root
webpack.config.ts:
externals: ['react/jsx-runtime', 'react/jsx-dev-runtime'],Commit:
git add -A && git diff --cached --quiet || git commit -m "feat: externalize jsx-runtime" --no-verifyStep 5: Bump grafanaDependency
jq -r '.dependencies.grafanaDependency' $PLUGIN_JSONIf not already >=12.3.0, update it. The create-plugin add in Step 3 may have already done this.
Step 6: Bump dependencies
Faro (if present)
grep '"@grafana/faro' $PKG_JSON| Package | Target |
|---|---|
@grafana/faro-react | ^2.2.3 |
@grafana/faro-web-sdk | ^2.2.3 |
@grafana/faro-web-tracing | ^2.0.0 |
Grafana packages
grep '"@grafana/' $PKG_JSON | grep -v faro | grep -v create-pluginBump @grafana/data, @grafana/runtime, @grafana/schema, @grafana/ui to ^12.2.0 or later.
Add @grafana/i18n@^12.2.0 if the plugin uses translations or @grafana/scenes requires it.
React types
Bump react and react-dom to ^18.3.0 (surfaces React 19 issues early).
Add @types/react@^18.3.0 and @types/react-dom@^18.3.0 to devDependencies if missing.
Remove deprecated packages
Remove from devDependencies if present:
eslint-plugin-deprecation(replaced by@typescript-eslint/no-deprecated)@types/testing-library__jest-dom(replaced bysetupTests.d.ts)
Broken transitive dependencies
If yarn install fails with a stale git reference, do not edit yarn.lock. Add a resolutions entry:
"resolutions": {
"<package-name>": "<working-version-or-git-ref>"
}Then delete yarn.lock and node_modules and reinstall:
rm -rf node_modules yarn.lock
yarn install --ignore-engines 2>&1 | tail -10Step 7: Fix unmet @openfeature/web-sdk peer dependency
@grafana/runtime depends on @openfeature/react-sdk which has @openfeature/web-sdk as a
peer dependency. Yarn v1 (classic) does not auto-install peer deps.
Check if the plugin uses yarn classic:
yarn --version 2>&1 | head -1If version starts with 1., check for warnings:
yarn install --ignore-engines 2>&1 | grep "unmet peer dependency.*openfeature/web-sdk"If warnings are found:
yarn add -D @openfeature/web-sdk @openfeature/core --ignore-enginesSkip condition: Yarn v2+ or npm v7+ (peer deps are auto-installed).
Step 8: Fix source code issues
grep -rn "ReactDOM\.render\|ReactDOM\.unmountComponentAtNode\|ReactDOM\.findDOMNode" src/ --include="*.tsx" --include="*.ts"
grep -rn "\.defaultProps\s*=" src/ --include="*.tsx" --include="*.ts"
grep -rn "\.propTypes\s*=" src/ --include="*.tsx" --include="*.ts"
grep -rn "contextTypes\|getChildContext" src/ --include="*.tsx" --include="*.ts"
grep -rn "createFactory" src/ --include="*.tsx" --include="*.ts"
grep -rn "ChangeEvent<HTMLInputElement>" src/ --include="*.tsx" --include="*.ts"| Pattern | Fix |
|---|---|
ReactDOM.render() | createRoot(container).render(element) |
defaultProps on function components | Move to destructured parameter defaults |
defaultProps on class components | Leave — still works |
propTypes | Remove |
contextTypes / getChildContext | Use React.createContext() + useContext() |
createFactory | Use JSX or createElement() |
ChangeEvent<HTMLInputElement> on checkbox | Change to FormEvent<HTMLInputElement> |
Step 9: Build, typecheck, test
rm -rf node_modules dist
yarn install --ignore-engines 2>&1 | tail -10
yarn build 2>&1 | tail -10
yarn typecheck 2>&1 | tail -10
yarn test --watchAll=false 2>&1 | tail -10| Error | Fix |
|---|---|
Cannot find module 'react/jsx-runtime' | Step 4 not applied — re-run create-plugin add |
Cannot find module '@openfeature/web-sdk' | Step 7 — yarn add -D @openfeature/web-sdk @openfeature/core |
Can't resolve '@grafana/i18n' | yarn add @grafana/i18n@^12.2.0 |
Cannot read properties of undefined (reading 'ReactCurrentOwner') | Bump @grafana-cloud/* packages — see Step 6 |
aria-label is missing on icon-only Button | Add aria-label prop (newer @grafana/ui requires it) |
Stale git hash in yarn.lock | Add resolutions in package.json, delete lockfile, reinstall |
For detailed known issues (i18n crash, @grafana/schema type breaks, publicPath mismatch), see
references/known-issues.md.
Step 10: Update CI (if applicable)
grep -rn "plugin-ci-workflows\|e2e-version" .github/workflows/ 2>/dev/nullplugin-ci-workflows@mainor >= 6.0.0 → already tests React 19. No changes needed.plugin-actions/e2e-version→ addskip-grafana-react-19-preview-image: false.Neither found → test manually with
GRAFANA_VERSION=dev-preview-react19 docker compose up --build.
Step 11: Squash and push
git reset --soft origin/main
git add -A
git commit -m "fix: Prepare plugin for React 19 compatibility"Commit message body should list: create-plugin version change, ESLint 9 migration, key dependency bumps, and any source code fixes.
References
grafana-collector-app #1337 — full migration with create-plugin update + source fixes
grafana/scenes issues — upstream i18n tracking
Files
- ATTRIBUTION.mdAdded by AutoGineer873 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md11.9 KiB
- references/known-issues.md4.6 KiB
references/known-issues.md
Known Issues: React 19 Plugin Migration
ReactCurrentOwner / ReactCurrentDispatcher crash from @grafana-cloud packages
Plugins using @grafana-cloud/* packages may crash immediately on load with:
TypeError: Cannot read properties of undefined (reading 'ReactCurrentOwner')or:
TypeError: Cannot read properties of undefined (reading 'ReactCurrentDispatcher')Root cause: Older @grafana-cloud package builds did not externalize react/jsx-runtime.
Webpack bundled a copy of react/jsx-runtime from React 18 into each package's UMD output.
At runtime with React 19, the bundled shim accesses
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner (or
ReactCurrentDispatcher), which no longer exists in React 19.
Fix: Bump all @grafana-cloud/* dependencies to versions that include the jsx-runtime fix.
Check each package's changelog for the version that adds externalize-jsx-runtime.
Minimum versions (check your registry for the latest):
| Package | Minimum version |
|---|---|
@grafana-cloud/access-policies | 3.12.0 |
@grafana-cloud/activation-api | 3.9.0 |
@grafana-cloud/alloy-configurator | 2.3.0 |
@grafana-cloud/asserts-ui | 3.8.0 |
@grafana-cloud/collector | 3.12.0 |
@grafana-cloud/fleet-management-api | 3.12.0 |
@grafana-cloud/grafana-api | 3.8.0 |
@grafana-cloud/grafana-com-api | 3.9.0 |
@grafana-cloud/integrations-api | 3.8.0 |
@grafana-cloud/ui | 3.10.0 |
t() was called before i18n was initialized (plugins using @grafana/scenes)
Plugins using @grafana/scenes >= 6.38 may crash in dev mode with:
t() was called before i18n was initialized. Make sure to call initPluginTranslations()Root cause: @grafana/i18n is not in the plugin externals or Grafana's sharedDependenciesMap,
so webpack bundles a separate copy with its own uninitialized tFunc.
Check if affected:
grep -rn "@grafana/scenes" $PKG_JSONWorkaround A: Explicit initialization — call initPluginTranslations with scenes'
loadResources before the app renders (e.g. in module.tsx):
import { initPluginTranslations } from '@grafana/i18n';
import { loadResources } from '@grafana/scenes';
await initPluginTranslations('grafana-scenes', [loadResources]);Workaround B: Webpack alias — deduplicate @grafana/i18n copies:
import path from 'path';
// Inside the merge config:
resolve: {
alias: {
'@grafana/i18n': path.resolve(process.cwd(), 'node_modules/@grafana/i18n'),
},
},Workaround C: Patch dev-mode throw — if A and B don't resolve it:
yarn add -D string-replace-loadermodule: {
rules: [
{
test: /node_modules\/@grafana\/i18n/,
loader: 'string-replace-loader',
options: {
search: "throw new Error\\('t\\(\\) was called before i18n was initialized",
replace: "tFunc = getI18nInstance().t; // patched: use production fallback in dev",
flags: '',
},
},
],
},Tracking issue: grafana/scenes #1322
Type errors from @grafana/schema 12.4.0
^12.2.0 resolves to 12.4.0 which introduced breaking type changes:
footerremoved from table panelOptionstype (moved toTableFieldOptions)hiddenremoved fromTableFieldOptions(usehideFrom: { legend: true, tooltip: true, viz: true })React.ComponentProps<typeof Button>can no longer be extended withinterface extends(use type intersection)
If the plugin uses table panel types from @grafana/schema, pin to avoid the break:
"resolutions": {
"@grafana/schema": "12.3.4"
}react/jsx-runtime 404 at runtime
The externalized react/jsx-runtime requires Grafana >= 12.3.0 to provide it via SystemJS.
Verify the docker-compose default is >= 12.3.0:
grep "grafana_version" .config/docker-compose-base.yaml docker-compose.yaml 2>/dev/nullIf it shows a version < 12.3.0, bump it.
ESLint import/no-unused-modules error in flat config
In ESLint flat config, eslint-plugin-import's no-unused-modules rule can error. If this
affects the plugin, keep a minimal .eslintrc with only ignorePatterns (known limitation).
Chunks cache forever after webpack alias change
If adding a webpack resolve alias, ensure output.chunkFilename includes [contenthash] so
users receive updated chunks after deploy.
Dev build sizes are huge
Always measure with a production build, not dev:
rm -rf dist node_modules/.cache
yarn build --env productionRequirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs a command-line tool, Needs Node.js
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Grafana Labs
- Publisher
- Grafana Labs (Official)
- Source
- grafana/skills · skills/grafana-plugins/react-19-plugin-migration · commit 8fb72a5
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Grafana Labs or Grafana Labs.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download react-19-plugin-migration.zip