Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

TypeScript says your Router is missing location and navigator

ErrorType '{ children: Element[]; }' is missing the following properties from type 'RouterProps': location, navigator

Short answer

You rendered the low-level Router component, which requires you to pass location and navigator yourself. React Router's docs say you almost never render it directly. Use BrowserRouter for a browser app (MemoryRouter or StaticRouter elsewhere) and let it create those props for you.

  • Applies to React Router 6.30, React 19, TypeScript 5
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Look at what your root file imports and renders. The error means the component named Router is the low-level one.

    grep -rn -E "import .*Router|<Router" src/
  2. 2Match what you see, then jump to its fix

    1. 1The root renders <Router> with only childrenRouter was imported where BrowserRouter was meantFix
    2. 2Custom history handling, and no higher-level router fitsYou really need Router, so both props must be suppliedFix

What does the error look like?

  • Type '{ children: Element[]; }' is missing the following properties from type 'RouterProps': location, navigator

Cause 1 of 2

Router was imported where BrowserRouter was meant

1Check

Router is the shared low-level interface of all router components, and its props type makes location and navigator required.

grep -rn "<Router" src/

2Fix

Swap it for the higher-level router that matches your environment. In a browser app that is BrowserRouter, which needs no location or navigator.

import { BrowserRouter } from "react-router-dom";

root.render(
  <BrowserRouter>
    <App />
  </BrowserRouter>
);

3Verify

Run the type check.

npx tsc --noEmit

Confirmed by reactrouter.com

Did this fix it?

Cause 2 of 2

You really need Router, so both props must be supplied

1Check

RouterProps declares location (a Location-like object or a string) and navigator as required. Without them the compiler cannot accept the element.

grep -rn -B2 -A6 "<Router" src/

2Fix

Pass both. Remember that one router is enough for an app; do not nest routers.

<Router location={location} navigator={navigator}>
  <App />
</Router>

3Verify

Run the type check and open the app.

npx tsc --noEmit

Confirmed by reactrouter.com

Did this fix it?

How do I stop it coming back?

  • Let your editor import BrowserRouter from the router package, not Router.
  • Keep a single router at the root of the app.
  • Run tsc in CI so type errors in the router setup fail the build.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

TypeScript rejects MUI Data Grid columns that set a type

A TypeScript error inside a column's renderCell callback

A columns array declared without a type is inferred with type as a plain string, which the Data Grid's column type union does not accept.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.