-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Description
What is the new or updated feature that you are suggesting?
We should be able to remove the basename
from <Link to
in some cases. While it's very useful to provide a basename
when the app is served from a sub-directory on the server, we may want to disable this feature in some Link
s. For instance, if the server serves two React Router apps in two different sub-directories and we want to have a client-side (soft) navigation between them.
Example
git clone git@github.com:alexlbr/micro-frontend-react-router-example.git
cd micro-frontend-react-router-example
yarn && yarn dev
The example is running two React Router apps inside a "parent" Nextjs application. React Router App 1 is served from the sub-directory "/react-router-1-sub-pages". React Router App 2 is served from the sub-directory "/react-router-2-sub-pages". The Nexjs app is served from the root directory "/".
Steps to reproduce my problem:
- Navigate to http://localhost:3000
- Click on "React Router 1"
- Click on "Lola". Navigation works inside React Router 1 because
basename
is "/react-router-1-sub-pages" - Click on "React Router 2" at the top of the page
- Click on "Visit React Router 1" ❌ . I'd like to escape
basename
in this case
Why should this feature be included?
This would make it possible to use React Router with micro-frontends and:
- Have soft navigations between different apps.
- Have multiple independent Routers.