Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time


A <Router> that keeps the history of your "URL" in memory (does not read or write to the address bar). Useful in tests and non-browser environments like React Native.

  <App />

initialEntries: array

An array of locations in the history stack. These may be full-blown location objects with { pathname, search, hash, state } or simple string URLs.

  initialEntries={["/one", "/two", { pathname: "/three" }]}
  <App />

initialIndex: number

The initial location's index in the array of initialEntries.

getUserConfirmation: func

A function to use to confirm navigation. You must use this option when using <MemoryRouter> directly with a <Prompt>.

keyLength: number

The length of location.key. Defaults to 6.

<MemoryRouter keyLength={12} />

children: node

The child elements to render.

Note: On React < 16 you must use a single child element since a render method cannot return more than one element. If you need more than one element, you might try wrapping them in an extra <div> or <React.Fragment>.