Skip to content

[Docs]: Current instructions for installing react-router do not work on Declarative Mode #14304

@LuckyT89

Description

@LuckyT89

Describe what's incorrect/missing in the documentation

I am new to React Router and wanted to start experimenting with a simple project. Looking at the docs, it seemed like Declarative Mode was the way to go. I followed the short instructions here: https://reactrouter.com/start/declarative/installation. I created a new project and installed react-router. However once this was done I could not import BrowserRouter. The line import { BrowserRouter } from "react-router"; gave an error saying Module '"react-router"' has no exported member 'BrowserRouter'.

Looking at my package.json, following these instructions and running npm i react-router added "react-router": "^6.30.1". From doing some searching it seems the current version of React Router (and what the docs are showing) is version 7. I tried creating a new project and then installed react-router using the following modified line: npm i react-router@latest. Looking at the package.json I saw this added "react-router": "^7.8.2" and from there I was able to successfully import BrowserRouter.

I think the docs should be updated to modify that specific line on installing react-router. I believe this may also apply to the installation page for Data Mode as well but I have not tested it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions