Hi users!
Grafana 10 added support for using react-router@6 in your app plugins. While Grafana 10 and Grafana 11 are still supporting app plugins using react-router@5, this approach is becoming deprecated in Grafana 11 and we suggest that you update your plugin as soon as you can.
You are affected if:
You have an app plugin which is relying on frontend routing.
Migration path:
1. Enable using react-router v6
Add the following in your plugin build config file - <path-to-your-plugin>/.cprc.json
{
"features": {
"useReactRouterV6": true
}
}
2. Update the plugin build config
Make sure that you have your git working tree clean, and update using create-plugin:
# Update the build config
npx @grafana/create-plugin@latest update
# Install dependency updates
npm install # yarn install | pnpm install
3. Update your code
There are some things that you will need to change in your plugins code as well:
- Use
<Routes>
instead of<Switch>
<Route exact>
is gone<Route path>
and<Link to>
are now relative- Etc. (For the complete list please check out the offical react-router v5 to v6 migration guide.)
Please also check out the Grafana v9.x → v10.x migration guide on our website for more information.
Happy coding!