Documentation Index
Fetch the complete documentation index at: https://mintlify.com/remix-run/react-router/llms.txt
Use this file to discover all available pages before exploring further.
unstable_HistoryRouter
A low-level declarative<Router> that accepts a pre-instantiated history object. This component is primarily for advanced use cases where you need full control over the history instance.
Import
Type Declaration
Props
A pre-instantiated history object from the
history library. This is the only required prop.Important: You must use the exact same version of the history library that React Router uses internally to avoid bundle size issues.The base URL for all locations. If your app is served from a subdirectory, set this to the subdirectory path.
Your route configuration, typically
<Routes> and <Route> elements.Control whether router state updates are wrapped in
React.startTransition.undefined(default): All state updates are wrapped instartTransitiontrue: Link/Form navigations and all state updates usestartTransitionfalse: Router doesn’t usestartTransitionat all
Examples
Basic Usage
With Custom History Configuration
Accessing History Outside React
One use case forHistoryRouter is when you need to access the history object outside of React components, such as in Redux middleware or analytics:
Testing with Custom History
When to Use
Useunstable_HistoryRouter only when:
- Redux integration: You need to access history in Redux middleware or sagas
- Analytics: You need to track navigation events outside React components
- Custom history: You need specific history library features not exposed by React Router
- Migration: You’re migrating from React Router v5 and need time to refactor
Alternatives
For most use cases, use these alternatives instead:BrowserRouter
Standard browser routing - use this for most apps
useNavigate
Programmatic navigation within React components
createBrowserRouter
Data Router API for loaders and actions
MemoryRouter
For testing - provides history without DOM
Migration from v5
If you’re migrating from React Router v5 and using a custom history:<BrowserRouter> or createBrowserRouter() and eliminate the custom history dependency.
See Also
<BrowserRouter>- Recommended for most apps<MemoryRouter>- For testinguseNavigate- Programmatic navigation hook