Skip to content

[Feature]: escape basename #8889

@alexlobera

Description

@alexlobera

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 Links. 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:

  1. Have soft navigations between different apps.
  2. Have multiple independent Routers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestUsed to close PRs that haven't gone through/been accepted the Proposal process yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions