Remove react-router dependency
New Feature Proposal
Please update the dependency to react-router to v7.
Description
Not sure if this counts as a bug or a feature, but I wanted to point out the fact that the currently used version of react-router is 4 years old. This could lead to security concerns, since versions prior to v6 are no longer supported with security updates, according to their GitHub page. Is updating to v7 feasible or would this have other side-effects which stop you from upgrading?
With piral-core you can actually select which version you want. So you are not constraint.
For piral itself we will keep the current selection as changing that is breaking (not only in an app shell, but - which makes it for us a no-go - potentially also in pilets (assumption: they use the shared dependency explicitly, i.e., with exports that might have changed or might not be available between v6 and v7)).
As the routing issue is not so delightful the future is actually router-less. This has already started a time ago and Piral v2 will not use any router (even though you can still use whatever you like on top of it, e.g., react-router v6 if you don't want to change).
We can leave the issue open, but I've transformed the title to indicate that going to v7 is not our goal - it's really being totally independent of react-router (or any router) in general.
Hi, Florian. I would like to add that the currently included version of React Router is not only unmaintained to the point that the live examples in their documentation do not work anymore, it is also a blocker to use React 19, since it is incompatible.
What are our options to move forward? Would you recommend to abandon piral package to build our own framework around piral-core? If so, how? I am trying to figure what would be the best way, in line with what is coming in Piral v2, so it could be that we better wait for it.
I am using React Router v5 (as well as other versions such as v6) with React 19 - can you express how its incompatible? There is no breaking change in React that makes using React Router incompatible AFAIK.
Also I am not sure if its critical that its unmaintained. We are not talking about some complicated piece of software here - it's a very simple router. The most critical piece is history and that is also as stable is it can get.
So while I understand the tendency to go with something more recent "old" or "outdated" does not mean buggy or not functional. In addition you can just upgrade to React Router v6 or v7 if you like. Piral supports both (as well as other routers).
can you express how its incompatible?
Sorry, I double-checked, and it is not really incompatible. The example project I used to quickly test the upgrade previously had issues that turn out not be really about the router and can be fixed easily. Thanks for sharing that it works, always good to have one less problem during an upgrade :)
Piral supports both (as well as other routers).
Can you please elaborate there? That is the core of my question: if we wanted to migrate to another router, what is the recommended approach when using the piral package (which includes react-router v5 in the app shell and exposes an API for registering routes from pilets)? How will the routing setup look like for Piral v2?
piral (the npm package) comes with fixed dependencies. It's great to get started but we always recommend to use piral-core instead:
- you select the versions of dependencies
- you select what plugins to use (no more things you don't use)
That being written: if you use piral-core and install, e.g., react-router in version 6, then it will automatically be picked and used. Likewise for the other supported routers.
Thanks for the quick reply. I removed already piral package and included plugins directly, so I can set the react-router-dom version we want (react-router is a transitive dep since v6 and can be removed), yet I think that although piral-core supports React Router v6 and v7 as you say, piral-page-layouts plugin does not—at least looks like it based on its dev dependency range and usage of some types from v5. Could that be?
Yes, it's a good point. This plugin is actually using things from React Router (independent if things such as useLocation work across versions - we want / should be router agnostic).
I'll update this plugin to be free of react-router.