--- title: MemoryRouter --- # ``
Type declaration ```tsx declare function MemoryRouter( props: MemoryRouterProps ): React.ReactElement; interface MemoryRouterProps { basename?: string; children?: React.ReactNode; initialEntries?: InitialEntry[]; initialIndex?: number; future?: FutureConfig; } ```
A `` stores its locations internally in an array. Unlike `` and ``, it isn't tied to an external source, like the history stack in a browser. This makes it ideal for scenarios where you need complete control over the history stack, like testing. - `` defaults to `["/"]` (a single entry at the root `/` URL) - `` defaults to the last index of `initialEntries` > **Tip:** > > Most of React Router's tests are written using a `` as the > source of truth, so you can see some great examples of using it by just > [browsing through our tests][tests]. ```tsx import * as React from "react"; import { create } from "react-test-renderer"; import { MemoryRouter, Routes, Route, } from "react-router-dom"; describe("My app", () => { it("renders correctly", () => { let renderer = create( }> } /> ); expect(renderer.toJSON()).toMatchSnapshot(); }); }); ``` ## `basename` Configure your application to run underneath a specific basename in the URL: ```jsx function App() { return ( {/* 👈 Renders at /app/ */} ); } ``` ## `future` An optional set of [Future Flags][api-development-strategy] to enable. We recommend opting into newly released future flags sooner rather than later to ease your eventual migration to v7. ```jsx function App() { return ( {/*...*/} ); } ``` [defaultview]: https://developer.mozilla.org/en-US/docs/Web/API/Document/defaultView [api-development-strategy]: ../guides/api-development-strategy [tests]: https://github.com/remix-run/react-router/tree/main/packages/react-router/__tests__