React minimalist SPA router

https://github.com/molefrog/wouter

npm i --save wouter
import { Router, Switch, Route, Redirect } from "wouter";
import { useHashLocation } from "wouter/use-hash-location";
import { BaseLayout } from "./layouts/BaseLayout";
import { ProtectedRoute } from "./layouts/ProtectedRoute";
import { DashboardPage } from "./pages/DashboardPage";
import { NotFoundPage } from "./pages/NotFoundPage";
import { MicrosoftRedirect } from "./components/MicrosoftRedirect";
import { LoginView } from "./pages/login/LoginView";

export function Routes() {
    const [location] = useHashLocation();

    if (location.startsWith("/code="))
        return <MicrosoftRedirect />;


    return <Router hook={useHashLocation}>
        <Switch>
            {/* Public routes */}
            <Route path="/" component={() => <Redirect to="/dashboard" />} />
            <Route path="/login" component={LoginView} />

            {/* Protected routes */}
            <Route path="/dashboard">
                <BaseLayout>
                    <ProtectedRoute>
                        <DashboardPage />
                    </ProtectedRoute>
                </BaseLayout>
            </Route>

            {/* 404 */}
            <Route>
                <NotFoundPage />
            </Route>
            </Switch>
    </Router>;
}


// navigate:
import { navigate } from "wouter/use-hash-location";

// Link
import { Link } from "wouter";
<Link href="/">Home</Link>

102470cookie-checkReact minimalist SPA router