Routing

Nostalgie routing is exposed by the nostalgie/routing module.

Currently, the routing support in Nostalgie is a direct export of a subset of the features in react-router-dom. These are re-exported so that Nostalgie doesn't accidentally pick up multiple competing copies of the (react-router-dom)[https://npm.im/react-router-dom] package.

Nostalgie integrates deeply with react-router-dom and as such, there is no need to wrap your app in a <BrowserRouter />. Your page will be automatically wrapped with a <BrowserRouter> during CSR and it will be wrapped with a <StaticRouter> during SSR.

import { Link, Route, Switch } from 'nostalgie/routing';

export default function App() {
  return (
    <>
      <nav>
        <Link to="/a">Page A</Link>
        <Link to="/b">Page B</Link>
      </nav>
      <main>
        <Switch>
          <Route exact path="/a">
            Page A Content
          </Route>
          <Route exact path="/b">
            Page B Content
          </Route>
          <Route path="/">Initial Content</Route>
        </Switch>
      </main>
    </>
  );
}