main (6.23.1)dev


Type declaration
declare function HashRouter(
  props: HashRouterProps
): React.ReactElement;

interface HashRouterProps {
  basename?: string;
  children?: React.ReactNode;
  future?: FutureConfig;
  window?: Window;

<HashRouter> is for use in web browsers when the URL should not (or cannot) be sent to the server for some reason. This may happen in some shared hosting scenarios where you do not have full control over the server. In these situations, <HashRouter> makes it possible to store the current location in the hash portion of the current URL, so it is never sent to the server.

import * as React from "react";
import * as ReactDOM from "react-dom";
import { HashRouter } from "react-router-dom";

    {/* The rest of your app goes here */}

We strongly recommend you do not use HashRouter unless you absolutely have to.


Configure your application to run underneath a specific basename in the URL:

function App() {
  return (
    <HashRouter basename="/app">
        <Route path="/" /> {/* πŸ‘ˆ Renders at /#/app/ */}


An optional set of Future Flags to enable. We recommend opting into newly released future flags sooner rather than later to ease your eventual migration to v7.

function App() {
  return (
    <HashRouter future={{ v7_startTransition: true }}>


HashRouter defaults to using the current document's defaultView, but it may also be used to track changes to another window's URL, in an <iframe>, for example.

Docs and examples CC 4.0